aboutsummaryrefslogtreecommitdiff
path: root/libX11/modules/im/ximcp
diff options
context:
space:
mode:
Diffstat (limited to 'libX11/modules/im/ximcp')
-rw-r--r--libX11/modules/im/ximcp/imCallbk.c17
-rw-r--r--libX11/modules/im/ximcp/imDefIc.c52
-rw-r--r--libX11/modules/im/ximcp/imDefIm.c40
-rw-r--r--libX11/modules/im/ximcp/imDefLkup.c16
-rw-r--r--libX11/modules/im/ximcp/imDispch.c2
-rw-r--r--libX11/modules/im/ximcp/imExten.c6
-rw-r--r--libX11/modules/im/ximcp/imInsClbk.c2
-rw-r--r--libX11/modules/im/ximcp/imInt.c4
-rw-r--r--libX11/modules/im/ximcp/imLcIc.c2
-rw-r--r--libX11/modules/im/ximcp/imLcIm.c2
-rw-r--r--libX11/modules/im/ximcp/imLcPrs.c35
-rw-r--r--libX11/modules/im/ximcp/imRm.c60
-rw-r--r--libX11/modules/im/ximcp/imRmAttr.c12
-rw-r--r--libX11/modules/im/ximcp/imThaiIc.c10
-rw-r--r--libX11/modules/im/ximcp/imThaiIm.c2
-rw-r--r--libX11/modules/im/ximcp/imTrX.c2
-rw-r--r--libX11/modules/im/ximcp/imTrans.c2
-rw-r--r--libX11/modules/im/ximcp/imTransR.c8
18 files changed, 152 insertions, 122 deletions
diff --git a/libX11/modules/im/ximcp/imCallbk.c b/libX11/modules/im/ximcp/imCallbk.c
index f57a8de31..edffac173 100644
--- a/libX11/modules/im/ximcp/imCallbk.c
+++ b/libX11/modules/im/ximcp/imCallbk.c
@@ -230,9 +230,9 @@ _XimCbDispatch(Xim xim,
/* queue the protocol
*/
XimPendingCallback pcb;
- char *proto_buf = (proto_len > 0) ? (char*)Xmalloc(proto_len) : NULL;
+ char *proto_buf = (proto_len > 0) ? Xmalloc(proto_len) : NULL;
- pcb = (XimPendingCallback)Xmalloc(sizeof(XimPendingCallbackRec));
+ pcb = Xmalloc(sizeof(XimPendingCallbackRec));
if (pcb && (proto_len <= 0 || proto_buf)) {
if (proto_len > 0)
memcpy(proto_buf, proto, proto_len);
@@ -339,7 +339,7 @@ _XimStrConversionCallback(Xim im,
2 + length_in_bytes +
XIM_PAD(2 + length_in_bytes) +
2 + 2 + sz_CARD32 * cbrec.text->length;
- buf = (CARD8*)Xmalloc(buf_len);
+ buf = Xmalloc(buf_len);
}
_XimSetHeader((XPointer)buf, XIM_STR_CONVERSION_REPLY, 0, &buf_len);
buf_len -= XIM_HEADER_SIZE; /* added by _XimSetHeader (HACK) */
@@ -461,12 +461,12 @@ _read_text_from_packet(Xim im,
return;
}
- *text_ptr = text = (XIMText*)Xmalloc(sizeof(XIMText));
+ *text_ptr = text = Xmalloc(sizeof(XIMText));
if (text == (XIMText*)NULL) return;
tmp_len = (int)*(CARD16*)buf;
buf += sz_CARD16;
- if ((tmp_buf = (char*)Xmalloc(tmp_len + 1))) {
+ if ((tmp_buf = Xmalloc(tmp_len + 1))) {
memcpy(tmp_buf, buf, tmp_len);
tmp_buf[tmp_len] = '\0';
@@ -477,11 +477,10 @@ _read_text_from_packet(Xim im,
if (s != XLookupNone) {
#ifndef NO_DEC_I18N_FIX
/* Allow for NULL-terminated */
- if ((text->string.multi_byte =
- (char*)Xmalloc(text->length *
+ if ((text->string.multi_byte = Xmalloc(text->length *
XLC_PUBLIC(im->core.lcd,mb_cur_max) + 1))) {
#else
- if (text->string.multi_byte = (char*)Xmalloc(text->length+1)) {
+ if (text->string.multi_byte = Xmalloc(text->length+1)) {
#endif
int tmp;
#ifndef NO_DEC_I18N_FIX
@@ -530,7 +529,7 @@ _read_text_from_packet(Xim im,
i = (int)*(CARD16*)buf; buf += sz_CARD16;
buf += sz_CARD16; /* skip `unused' */
- text->feedback = (XIMFeedback*)Xmalloc(i*(sizeof(XIMFeedback)/sizeof(CARD32)));
+ text->feedback = Xmalloc(i*(sizeof(XIMFeedback)/sizeof(CARD32)));
j = 0;
while (i > 0) {
text->feedback[j] = (XIMFeedback)*(CARD32*)buf;
diff --git a/libX11/modules/im/ximcp/imDefIc.c b/libX11/modules/im/ximcp/imDefIc.c
index f7e484789..9610a0f11 100644
--- a/libX11/modules/im/ximcp/imDefIc.c
+++ b/libX11/modules/im/ximcp/imDefIc.c
@@ -108,7 +108,7 @@ _XimReCreateIC(ic)
XPointer preply;
int ret_code;
- if (!(save_ic = (Xic)Xmalloc(sizeof(XicRec))))
+ if (!(save_ic = Xmalloc(sizeof(XicRec))))
return False;
memcpy((char *)save_ic, (char *)ic, sizeof(XicRec));
@@ -120,7 +120,7 @@ _XimReCreateIC(ic)
num = im->core.ic_num_resources;
buf_size = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(buf_size)))
+ if (!(res = Xmalloc(buf_size)))
goto ErrorOnReCreateIC;
(void)memcpy((char *)res, (char *)im->core.ic_resources, buf_size);
ic->private.proto.ic_resources = res;
@@ -128,7 +128,7 @@ _XimReCreateIC(ic)
num = im->private.proto.ic_num_inner_resources;
buf_size = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(buf_size)))
+ if (!(res = Xmalloc(buf_size)))
goto ErrorOnReCreateIC;
(void)memcpy((char *)res,
(char *)im->private.proto.ic_inner_resources, buf_size);
@@ -164,13 +164,13 @@ _XimReCreateIC(ic)
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
goto ErrorOnReCreateIC;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
goto ErrorOnReCreateIC;
}
@@ -203,7 +203,7 @@ _XimReCreateIC(ic)
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimCreateICCheck, 0);
if (ret_code != XIM_TRUE) {
@@ -351,7 +351,7 @@ _XimProtoGetICValues(
+ sizeof(INT16)
+ XIM_PAD(2 + buf_size);
- if (!(buf = (CARD8 *)Xmalloc(buf_size)))
+ if (!(buf = Xmalloc(buf_size)))
return arg->name;
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
@@ -385,7 +385,7 @@ _XimProtoGetICValues(
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(len);
+ preply = Xmalloc(len);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimGetICValuesCheck, (XPointer)ic);
if (ret_code != XIM_TRUE) {
@@ -465,7 +465,7 @@ _XimCheckNestedQuarkList(quark_list, idx, num_quark, arg, separator)
quark, separator)) {
continue;
}
- if (!(tmp = (XrmQuark *)Xmalloc((sizeof(XrmQuark) * (n_quark + 1))))) {
+ if (!(tmp = Xmalloc((sizeof(XrmQuark) * (n_quark + 1))))) {
*quark_list = q_list;
*num_quark = n_quark;
return False;
@@ -535,7 +535,7 @@ _XimSaveICValues(ic, arg)
for (pp = (XIMArg *)p->value, nn = 0;
pp && pp->name; pp++, nn++);
- if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ if (!(tmp = Xrealloc(quark_list,
(sizeof(XrmQuark) * (num_quark + nn + 2))))) {
ic->private.proto.saved_icvalues = quark_list;
ic->private.proto.num_saved_icvalues = num_quark;
@@ -562,7 +562,7 @@ _XimSaveICValues(ic, arg)
if (_XimCheckICQuarkList(quark_list, num_quark, quark, &idx)) {
continue;
}
- if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ if (!(tmp = Xrealloc(quark_list,
(sizeof(XrmQuark) * (num_quark + 1))))) {
ic->private.proto.saved_icvalues = quark_list;
ic->private.proto.num_saved_icvalues = num_quark;
@@ -589,7 +589,7 @@ _XimSaveICValues(ic, arg)
}
}
- if (!(quark_list = (XrmQuark *)Xmalloc(sizeof(XrmQuark) * n))) {
+ if (!(quark_list = Xmalloc(sizeof(XrmQuark) * n))) {
return False;
}
@@ -731,13 +731,13 @@ _XimProtoSetICValues(
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
return tmp_name;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
return tmp_name;
}
@@ -781,7 +781,7 @@ _XimProtoSetICValues(
preply = reply;
} else if (ret_code == XIM_OVERFLOW) {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimSetICValuesCheck, (XPointer)ic);
if (ret_code != XIM_TRUE) {
@@ -915,7 +915,7 @@ _XimProtoDestroyIC(
_XimDestroyICCheck, (XPointer)ic);
if (ret_code == XIM_OVERFLOW) {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
(void)_XimRead(im, &len, preply, buf_size,
_XimDestroyICCheck, (XPointer)ic);
Xfree(preply);
@@ -1115,7 +1115,7 @@ _XimProtoReset(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimResetICCheck, (XPointer)ic);
if (ret_code != XIM_TRUE) {
@@ -1166,7 +1166,7 @@ _XimCommitedMbString(
if ( len == 0 )
return( NULL );
- if (!(commit = (char *)Xmalloc(len + 1)))
+ if (!(commit = Xmalloc(len + 1)))
goto Error_On_Reset;
str = commit;
@@ -1223,7 +1223,7 @@ _XimCommitedWcString(
if ( len == 0 )
return( (wchar_t *)NULL );
- if (!(commit = (char *)Xmalloc(len + 1)))
+ if (!(commit = Xmalloc(len + 1)))
goto Error_On_Reset;
str = commit;
@@ -1282,7 +1282,7 @@ _XimCommitedUtf8String(
if ( len == 0 )
return( NULL );
- if (!(commit = (char *)Xmalloc(len + 1)))
+ if (!(commit = Xmalloc(len + 1)))
goto Error_On_Reset;
str = commit;
@@ -1395,7 +1395,7 @@ _XimReconnectModeCreateIC(ic)
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(len)))
+ if (!(res = Xmalloc(len)))
return False;
(void)memcpy((char *)res, (char *)im->core.ic_resources, len);
ic->private.proto.ic_resources = res;
@@ -1457,7 +1457,7 @@ _XimProtoCreateIC(
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(len)))
+ if (!(res = Xmalloc(len)))
goto ErrorOnCreatingIC;
(void)memcpy((char *)res, (char *)im->core.ic_resources, len);
ic->private.proto.ic_resources = res;
@@ -1485,7 +1485,7 @@ _XimProtoCreateIC(
num = im->private.proto.ic_num_inner_resources;
len = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(len)))
+ if (!(res = Xmalloc(len)))
goto ErrorOnCreatingIC;
(void)memcpy((char *)res,
(char *)im->private.proto.ic_inner_resources, len);
@@ -1519,13 +1519,13 @@ _XimProtoCreateIC(
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
goto ErrorOnCreatingIC;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
goto ErrorOnCreatingIC;
}
@@ -1565,7 +1565,7 @@ _XimProtoCreateIC(
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimCreateICCheck, 0);
if (ret_code != XIM_TRUE) {
diff --git a/libX11/modules/im/ximcp/imDefIm.c b/libX11/modules/im/ximcp/imDefIm.c
index 7cac1d300..9168135e1 100644
--- a/libX11/modules/im/ximcp/imDefIm.c
+++ b/libX11/modules/im/ximcp/imDefIm.c
@@ -616,7 +616,7 @@ _XimConnection(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size, _XimAllRecv, 0);
if(ret_code != XIM_TRUE) {
Xfree(preply);
@@ -759,7 +759,7 @@ _XimDisconnect(
if(ret_code == XIM_OVERFLOW) {
if(len > 0) {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimDisconnectCheck, 0);
Xfree(preply);
@@ -831,7 +831,7 @@ _XimOpen(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimOpenCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -950,7 +950,7 @@ _XimClose(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size, _XimCloseCheck, 0);
if(ret_code != XIM_TRUE) {
Xfree(preply);
@@ -1105,10 +1105,10 @@ _XimProtoCloseIM(
next = ic->core.next;
#ifdef XIM_CONNECTABLE
if (!(!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im))) {
- Xfree ((char *) ic);
+ Xfree (ic);
}
#else
- Xfree ((char *) ic);
+ Xfree (ic);
#endif /* XIM_CONNECTABLE */
ic = next;
}
@@ -1173,7 +1173,7 @@ _XimSaveIMValues(
if (_XimCheckIMQuarkList(quark_list, num_quark, quark)) {
continue;
}
- if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ if (!(tmp = Xrealloc(quark_list,
(sizeof(XrmQuark) * (num_quark + 1))))) {
im->private.proto.saved_imvalues = quark_list;
im->private.proto.num_saved_imvalues = num_quark;
@@ -1190,7 +1190,7 @@ _XimSaveIMValues(
for (p = arg, n = 0; p && p->name; p++, n++);
- if (!(quark_list = (XrmQuark *)Xmalloc(sizeof(XrmQuark) * n))) {
+ if (!(quark_list = Xmalloc(sizeof(XrmQuark) * n))) {
return False;
}
@@ -1311,13 +1311,13 @@ _XimProtoSetIMValues(
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
return arg->name;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
return arg->name;
}
@@ -1353,7 +1353,7 @@ _XimProtoSetIMValues(
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, reply, buf_size,
_XimSetIMValuesCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -1462,7 +1462,7 @@ _XimProtoGetIMValues(
+ sizeof(INT16)
+ XIM_PAD(buf_size);
- if (!(buf = (CARD8 *)Xmalloc(buf_size)))
+ if (!(buf = Xmalloc(buf_size)))
return arg->name;
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
@@ -1494,7 +1494,7 @@ _XimProtoGetIMValues(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimGetIMValuesCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -1556,7 +1556,7 @@ _XimSetEncodingByName(
encoding_len = strlen(encoding);
compound_len = strlen("COMPOUND_TEXT");
*len = encoding_len + sizeof(BYTE) + compound_len + sizeof(BYTE);
- if (!(ret = (BYTE *)Xmalloc(*len))) {
+ if (!(ret = Xmalloc(*len))) {
return False;
}
*buf = (char *)ret;
@@ -1724,7 +1724,7 @@ _XimEncodingNegotiation(
+ sizeof(CARD16)
+ detail_len;
- if (!(buf = (CARD8 *)Xmalloc(XIM_HEADER_SIZE + len)))
+ if (!(buf = Xmalloc(XIM_HEADER_SIZE + len)))
goto free_detail_ptr;
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
@@ -1757,7 +1757,7 @@ _XimEncodingNegotiation(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimEncodingNegoCheck, 0);
if(ret_code != XIM_TRUE)
@@ -1844,13 +1844,13 @@ _XimSendSavedIMValues(
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
return False;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
return False;
}
@@ -1885,7 +1885,7 @@ _XimSendSavedIMValues(
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, reply, buf_size,
_XimSetIMValuesCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -1938,7 +1938,7 @@ _XimConnectServer(
{
Xim save_im;
- if (!(save_im = (Xim)Xmalloc(sizeof(XimRec))))
+ if (!(save_im = Xmalloc(sizeof(XimRec))))
return False;
memcpy((char *)save_im, (char *)im, sizeof(XimRec));
diff --git a/libX11/modules/im/ximcp/imDefLkup.c b/libX11/modules/im/ximcp/imDefLkup.c
index b4315894f..e88123493 100644
--- a/libX11/modules/im/ximcp/imDefLkup.c
+++ b/libX11/modules/im/ximcp/imDefLkup.c
@@ -162,7 +162,7 @@ _XimSync(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(len);
+ preply = Xmalloc(len);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimSyncCheck, (XPointer)ic);
if(ret_code != XIM_TRUE) {
@@ -302,7 +302,7 @@ _XimForwardEventCore(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(len);
+ preply = Xmalloc(len);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimSyncCheck, (XPointer)ic);
if(ret_code != XIM_TRUE) {
@@ -417,7 +417,7 @@ _XimRegisterTriggerkey(
len = buf_l[0]; /* length of on-keys */
len += sizeof(INT32); /* sizeof length of on-keys */
- if (!(key = (CARD32 *)Xmalloc(len))) {
+ if (!(key = Xmalloc(len))) {
_XimError(im, 0, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
@@ -434,7 +434,7 @@ _XimRegisterTriggerkey(
len = buf_l[0]; /* length of off-keys */
len += sizeof(INT32); /* sizeof length of off-keys */
- if (!(key = (CARD32 *)Xmalloc(len))) {
+ if (!(key = Xmalloc(len))) {
_XimError(im, 0, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
@@ -546,7 +546,7 @@ _XimTriggerNotify(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(len);
+ preply = Xmalloc(len);
ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
_XimTriggerNotifyCheck, (XPointer)ic);
if(ret_code != XIM_TRUE) {
@@ -579,7 +579,7 @@ _XimRegCommitInfo(
{
XimCommitInfo info;
- if (!(info = (XimCommitInfo)Xmalloc(sizeof(XimCommitInfoRec))))
+ if (!(info = Xmalloc(sizeof(XimCommitInfoRec))))
return False;
info->string = string;
info->string_len = string_len;
@@ -626,7 +626,7 @@ _XimProcKeySym(
{
Xim im = (Xim)ic->core.im;
- if (!(*xim_keysym = (KeySym *)Xmalloc(sizeof(KeySym)))) {
+ if (!(*xim_keysym = Xmalloc(sizeof(KeySym)))) {
_XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
@@ -648,7 +648,7 @@ _XimProcCommit(
Xim im = (Xim)ic->core.im;
char *string;
- if (!(string = (char *)Xmalloc(len + 1))) {
+ if (!(string = Xmalloc(len + 1))) {
_XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
diff --git a/libX11/modules/im/ximcp/imDispch.c b/libX11/modules/im/ximcp/imDispch.c
index 10c73ac0f..2c8e51b1f 100644
--- a/libX11/modules/im/ximcp/imDispch.c
+++ b/libX11/modules/im/ximcp/imDispch.c
@@ -49,7 +49,7 @@ _XimRegProtoIntrCallback(
{
XimProtoIntrRec *rec;
- if (!(rec = (XimProtoIntrRec *)Xmalloc(sizeof(XimProtoIntrRec))))
+ if (!(rec = Xmalloc(sizeof(XimProtoIntrRec))))
return False;
rec->func = proc;
rec->major_code = major_code;
diff --git a/libX11/modules/im/ximcp/imExten.c b/libX11/modules/im/ximcp/imExten.c
index e5a0b2723..58de32e60 100644
--- a/libX11/modules/im/ximcp/imExten.c
+++ b/libX11/modules/im/ximcp/imExten.c
@@ -271,7 +271,7 @@ _XimExtForwardKeyEvent(
preply = reply;
} else {
buf_sizex = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimExtForwardKeyEventCheck, (XPointer)ic);
if(ret_code != XIM_TRUE) {
@@ -436,7 +436,7 @@ _XimExtension(
+ len
+ XIM_PAD(len);
- if (!(buf = (CARD8 *)Xmalloc(buf_len)))
+ if (!(buf = Xmalloc(buf_len)))
return False;
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
@@ -465,7 +465,7 @@ _XimExtension(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, reply, buf_size,
_XimQueryExtensionCheck, 0);
if(ret_code != XIM_TRUE) {
diff --git a/libX11/modules/im/ximcp/imInsClbk.c b/libX11/modules/im/ximcp/imInsClbk.c
index b867d2f6f..d5527e036 100644
--- a/libX11/modules/im/ximcp/imInsClbk.c
+++ b/libX11/modules/im/ximcp/imInsClbk.c
@@ -168,7 +168,7 @@ _XimRegisterIMInstantiateCallback(
if( lock )
return( False );
- icb = (XimInstCallback)Xmalloc(sizeof(XimInstCallbackRec));
+ icb = Xmalloc(sizeof(XimInstCallbackRec));
if( !icb )
return( False );
icb->call = icb->destroy = False;
diff --git a/libX11/modules/im/ximcp/imInt.c b/libX11/modules/im/ximcp/imInt.c
index addae0abc..ee9f45122 100644
--- a/libX11/modules/im/ximcp/imInt.c
+++ b/libX11/modules/im/ximcp/imInt.c
@@ -48,7 +48,7 @@ _XimSetIMStructureList(
Xim *xim;
if(!(_XimCurrentIMlist)) {
- if(!(_XimCurrentIMlist = (Xim *)Xmalloc(sizeof(Xim))))
+ if(!(_XimCurrentIMlist = Xmalloc(sizeof(Xim))))
return False;
_XimCurrentIMlist[0] = im;
_XimCurrentIMcount = 1;
@@ -61,7 +61,7 @@ _XimSetIMStructureList(
}
}
if(i >= _XimCurrentIMcount) {
- if(!(xim = (Xim *)Xrealloc(_XimCurrentIMlist,
+ if(!(xim = Xrealloc(_XimCurrentIMlist,
((i + 1) * sizeof(Xim)))))
return False;
_XimCurrentIMlist = xim;
diff --git a/libX11/modules/im/ximcp/imLcIc.c b/libX11/modules/im/ximcp/imLcIc.c
index ef18453ae..635458990 100644
--- a/libX11/modules/im/ximcp/imLcIc.c
+++ b/libX11/modules/im/ximcp/imLcIc.c
@@ -158,7 +158,7 @@ _XimLocalCreateIC(
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
- if((res = (XIMResourceList)Xmalloc(len)) == (XIMResourceList)NULL) {
+ if((res = Xmalloc(len)) == (XIMResourceList)NULL) {
goto Set_Error;
}
(void)memcpy((char *)res, (char *)im->core.ic_resources, len);
diff --git a/libX11/modules/im/ximcp/imLcIm.c b/libX11/modules/im/ximcp/imLcIm.c
index 6456d7b31..3ab2dfc16 100644
--- a/libX11/modules/im/ximcp/imLcIm.c
+++ b/libX11/modules/im/ximcp/imLcIm.c
@@ -231,7 +231,7 @@ _XimLocalCloseIM(
while (ic) {
(*ic->methods->destroy) (ic);
next = ic->core.next;
- Xfree ((char *) ic);
+ Xfree (ic);
ic = next;
}
_XimLocalIMFree(im);
diff --git a/libX11/modules/im/ximcp/imLcPrs.c b/libX11/modules/im/ximcp/imLcPrs.c
index f3627a0d1..e9d5f7b78 100644
--- a/libX11/modules/im/ximcp/imLcPrs.c
+++ b/libX11/modules/im/ximcp/imLcPrs.c
@@ -574,9 +574,12 @@ parseline(
if (token == STRING) {
l = strlen(tokenbuf) + 1;
while (b->mbused + l > b->mbsize) {
- b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024;
- if (! (b->mb = Xrealloc (b->mb, b->mbsize)) )
+ DTCharIndex newsize = b->mbsize ? b->mbsize * 1.5 : 1024;
+ char *newmb = Xrealloc (b->mb, newsize);
+ if (newmb == NULL)
goto error;
+ b->mb = newmb;
+ b->mbsize = newsize;
}
rhs_string_mb = &b->mb[b->mbused];
b->mbused += l;
@@ -604,9 +607,12 @@ parseline(
l = get_mb_string(im, local_mb_buf, rhs_keysym);
while (b->mbused + l + 1 > b->mbsize) {
- b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024;
- if (! (b->mb = Xrealloc (b->mb, b->mbsize)) )
+ DTCharIndex newsize = b->mbsize ? b->mbsize * 1.5 : 1024;
+ char *newmb = Xrealloc (b->mb, newsize);
+ if (newmb == NULL)
goto error;
+ b->mb = newmb;
+ b->mbsize = newsize;
}
rhs_string_mb = &b->mb[b->mbused];
b->mbused += l + 1;
@@ -621,9 +627,12 @@ parseline(
local_wc_buf[l] = (wchar_t)'\0';
}
while (b->wcused + l + 1 > b->wcsize) {
- b->wcsize = b->wcsize ? b->wcsize * 1.5 : 512;
- if (! (b->wc = Xrealloc (b->wc, sizeof(wchar_t) * b->wcsize)) )
+ DTCharIndex newsize = b->wcsize ? b->wcsize * 1.5 : 512;
+ wchar_t *newwc = Xrealloc (b->wc, sizeof(wchar_t) * newsize);
+ if (newwc == NULL)
goto error;
+ b->wc = newwc;
+ b->wcsize = newsize;
}
rhs_string_wc = &b->wc[b->wcused];
b->wcused += l + 1;
@@ -634,9 +643,12 @@ parseline(
local_utf8_buf[l] = '\0';
}
while (b->utf8used + l + 1 > b->utf8size) {
- b->utf8size = b->utf8size ? b->utf8size * 1.5 : 1024;
- if (! (b->utf8 = Xrealloc (b->utf8, b->utf8size)) )
+ DTCharIndex newsize = b->utf8size ? b->utf8size * 1.5 : 1024;
+ char *newutf8 = Xrealloc (b->utf8, newsize);
+ if (newutf8 == NULL)
goto error;
+ b->utf8 = newutf8;
+ b->utf8size = newsize;
}
rhs_string_utf8 = &b->utf8[b->utf8used];
b->utf8used += l + 1;
@@ -657,9 +669,12 @@ parseline(
while (b->treeused >= b->treesize) {
DefTree *old = b->tree;
int oldsize = b->treesize;
- b->treesize = b->treesize ? b->treesize * 1.5 : 256;
- if (! (b->tree = Xrealloc (b->tree, sizeof(DefTree) * b->treesize)) )
+ int newsize = b->treesize ? b->treesize * 1.5 : 256;
+ DefTree *new = Xrealloc (b->tree, sizeof(DefTree) * newsize);
+ if (new == NULL)
goto error;
+ b->tree = new;
+ b->treesize = newsize;
if (top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize])
top = (DTIndex *) (((char *) top) + (((char *)b->tree)-(char *)old));
}
diff --git a/libX11/modules/im/ximcp/imRm.c b/libX11/modules/im/ximcp/imRm.c
index dd0b99ee2..cb9e1b2c5 100644
--- a/libX11/modules/im/ximcp/imRm.c
+++ b/libX11/modules/im/ximcp/imRm.c
@@ -75,8 +75,10 @@ _XimSetProtoResource(im)
{
char res_name_buf[256];
char* res_name;
+ size_t res_name_len;
char res_class_buf[256];
char* res_class;
+ size_t res_class_len;
char* str_type;
XrmValue value;
XIMStyle preedit_style = 0;
@@ -90,17 +92,31 @@ _XimSetProtoResource(im)
if (!im->core.rdb)
return;
- if (strlen (im->core.res_name) < 200) res_name = res_name_buf;
- else res_name = Xmalloc (strlen (im->core.res_name) + 50);
- if (strlen (im->core.res_class) < 200) res_class = res_class_buf;
- else res_class = Xmalloc (strlen (im->core.res_class) + 50);
+ res_name_len = strlen (im->core.res_name);
+ if (res_name_len < 200) {
+ res_name = res_name_buf;
+ res_name_len = sizeof(res_name_buf);
+ }
+ else {
+ res_name_len += 50;
+ res_name = Xmalloc (res_name_len);
+ }
+ res_class_len = strlen (im->core.res_class);
+ if (res_class_len < 200) {
+ res_class = res_class_buf;
+ res_class_len = sizeof(res_class_buf);
+ }
+ else {
+ res_class_len += 50;
+ res_class = Xmalloc (res_class_len);
+ }
/* pretend malloc always works */
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"useAuth");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"UseAuth");
@@ -111,11 +127,11 @@ _XimSetProtoResource(im)
}
}
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"delaybinding");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"Delaybinding");
@@ -126,11 +142,11 @@ _XimSetProtoResource(im)
}
}
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"reconnect");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"Reconnect");
@@ -147,11 +163,11 @@ _XimSetProtoResource(im)
return;
}
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"preeditDefaultStyle");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"PreeditDefaultStyle");
@@ -170,11 +186,11 @@ _XimSetProtoResource(im)
if(!preedit_style)
preedit_style = XIMPreeditNothing;
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"statusDefaultStyle");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"StatusDefaultStyle");
@@ -191,7 +207,7 @@ _XimSetProtoResource(im)
if(!status_style)
status_style = XIMStatusNothing;
- if(!(imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){
+ if(!(imstyles = Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){
if (res_name != res_name_buf) Xfree (res_name);
if (res_class != res_class_buf) Xfree (res_class);
return;
@@ -886,7 +902,7 @@ _XimEncodeHotKey(
}
len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
- if(!(tmp = (XPointer)Xmalloc(len))) {
+ if(!(tmp = Xmalloc(len))) {
return False;
}
@@ -1143,7 +1159,7 @@ _XimDecodeCallback(
XIMCallback *callback;
in = (XIMCallback *)((char *)top + info->offset);
- if(!(callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback)))) {
+ if(!(callback = Xmalloc(sizeof(XIMCallback)))) {
return False;
}
callback->client_data = in->client_data;
@@ -1256,7 +1272,7 @@ _XimDecodeHotKey(
in = *((XIMHotKeyTriggers **)((char *)top + info->offset));
num = in->num_hot_key;
len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
- if(!(tmp = (XPointer)Xmalloc(len))) {
+ if(!(tmp = Xmalloc(len))) {
return False;
}
@@ -1296,7 +1312,7 @@ _XimDecodeRectangle(
XRectangle *rect;
in = (XRectangle *)((char *)top + info->offset);
- if(!(rect = (XRectangle *)Xmalloc(sizeof(XRectangle)))) {
+ if(!(rect = Xmalloc(sizeof(XRectangle)))) {
return False;
}
*rect = *in;
@@ -1314,7 +1330,7 @@ _XimDecodeSpot(
XPoint *spot;
in = (XPoint *)((char *)top + info->offset);
- if(!(spot = (XPoint *)Xmalloc(sizeof(XPoint)))) {
+ if(!(spot = Xmalloc(sizeof(XPoint)))) {
return False;
}
*spot = *in;
@@ -2400,8 +2416,8 @@ _XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style)
list_num, ic_mode_quark[i]))) {
continue;
}
- res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset))
- | (*(unsigned short *)((char *)&ic_mode[i] + sts_offset)));
+ res->mode = ( (*(const unsigned short *)((const char *)&ic_mode[i] + pre_offset))
+ | (*(const unsigned short *)((const char *)&ic_mode[i] + sts_offset)));
}
return;
}
diff --git a/libX11/modules/im/ximcp/imRmAttr.c b/libX11/modules/im/ximcp/imRmAttr.c
index ef3ac2ca7..ad5290ee5 100644
--- a/libX11/modules/im/ximcp/imRmAttr.c
+++ b/libX11/modules/im/ximcp/imRmAttr.c
@@ -238,7 +238,7 @@ _XimAttributeToValue(
if (!(value))
return False;
- if (!(str = (char *)Xmalloc(data_len + 1)))
+ if (!(str = Xmalloc(data_len + 1)))
return False;
(void)memcpy(str, (char *)data, data_len);
@@ -262,7 +262,7 @@ _XimAttributeToValue(
return False;
alloc_len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
- if (!(p = (char *)Xmalloc(alloc_len)))
+ if (!(p = Xmalloc(alloc_len)))
return False;
rep = (XIMStyles *)p;
@@ -284,7 +284,7 @@ _XimAttributeToValue(
if (!(value))
return False;
- if (!(rep = (XRectangle *)Xmalloc(sizeof(XRectangle))))
+ if (!(rep = Xmalloc(sizeof(XRectangle))))
return False;
rep->x = data[0];
@@ -302,7 +302,7 @@ _XimAttributeToValue(
if (!(value))
return False;
- if (!(rep = (XPoint *)Xmalloc(sizeof(XPoint))))
+ if (!(rep = Xmalloc(sizeof(XPoint))))
return False;
rep->x = data[0];
@@ -325,7 +325,7 @@ _XimAttributeToValue(
if (!ic)
return False;
- if (!(base_name = (char *)Xmalloc(len + 1)))
+ if (!(base_name = Xmalloc(len + 1)))
return False;
(void)strncpy(base_name, (char *)&data[1], (int)len);
@@ -370,7 +370,7 @@ _XimAttributeToValue(
alloc_len = sizeof(XIMHotKeyTriggers)
+ sizeof(XIMHotKeyTrigger) * num;
- if (!(p = (char *)Xmalloc(alloc_len)))
+ if (!(p = Xmalloc(alloc_len)))
return False;
rep = (XIMHotKeyTriggers *)p;
diff --git a/libX11/modules/im/ximcp/imThaiIc.c b/libX11/modules/im/ximcp/imThaiIc.c
index a21fa2cb4..90da143f6 100644
--- a/libX11/modules/im/ximcp/imThaiIc.c
+++ b/libX11/modules/im/ximcp/imThaiIc.c
@@ -165,13 +165,13 @@ _XimThaiCreateIC(
ic->core.im = im;
ic->core.filter_events = KeyPressMask;
- if (! (ic->private.local.base.tree = tree = (DefTree *)Xmalloc(sizeof(DefTree)*3)) )
+ if (! (ic->private.local.base.tree = tree = Xmalloc(sizeof(DefTree)*3)) )
goto Set_Error;
- if (! (ic->private.local.base.mb = (char *)Xmalloc(21)) )
+ if (! (ic->private.local.base.mb = Xmalloc(21)) )
goto Set_Error;
- if (! (ic->private.local.base.wc = (wchar_t*)Xmalloc(sizeof(wchar_t)*21)) )
+ if (! (ic->private.local.base.wc = Xmalloc(sizeof(wchar_t)*21)) )
goto Set_Error;
- if (! (ic->private.local.base.utf8 = (char *)Xmalloc(21)) )
+ if (! (ic->private.local.base.utf8 = Xmalloc(21)) )
goto Set_Error;
ic->private.local.context = 1;
tree[1].mb = 1;
@@ -188,7 +188,7 @@ _XimThaiCreateIC(
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
- if((res = (XIMResourceList)Xmalloc(len)) == (XIMResourceList)NULL) {
+ if((res = Xmalloc(len)) == (XIMResourceList)NULL) {
goto Set_Error;
}
(void)memcpy((char *)res, (char *)im->core.ic_resources, len);
diff --git a/libX11/modules/im/ximcp/imThaiIm.c b/libX11/modules/im/ximcp/imThaiIm.c
index 793ed36e0..c96fad9fb 100644
--- a/libX11/modules/im/ximcp/imThaiIm.c
+++ b/libX11/modules/im/ximcp/imThaiIm.c
@@ -227,7 +227,7 @@ _XimThaiCloseIM(XIM xim)
while (ic) {
(*ic->methods->destroy) (ic);
next = ic->core.next;
- Xfree ((char *) ic);
+ Xfree (ic);
ic = next;
}
_XimThaiIMFree(im);
diff --git a/libX11/modules/im/ximcp/imTrX.c b/libX11/modules/im/ximcp/imTrX.c
index 76ff20e55..0fcf3581e 100644
--- a/libX11/modules/im/ximcp/imTrX.c
+++ b/libX11/modules/im/ximcp/imTrX.c
@@ -71,7 +71,7 @@ _XimXRegisterDispatcher(
XIntrCallbackPtr rec;
XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
- if (!(rec = (XIntrCallbackPtr)Xmalloc(sizeof(XIntrCallbackRec))))
+ if (!(rec = Xmalloc(sizeof(XIntrCallbackRec))))
return False;
rec->func = callback;
diff --git a/libX11/modules/im/ximcp/imTrans.c b/libX11/modules/im/ximcp/imTrans.c
index a8cd95e8f..ae644ab61 100644
--- a/libX11/modules/im/ximcp/imTrans.c
+++ b/libX11/modules/im/ximcp/imTrans.c
@@ -153,7 +153,7 @@ _XimTransRegisterDispatcher(
TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
TransIntrCallbackPtr rec;
- if (!(rec = (TransIntrCallbackPtr)Xmalloc(sizeof(TransIntrCallbackRec))))
+ if (!(rec = Xmalloc(sizeof(TransIntrCallbackRec))))
return False;
rec->func = callback;
diff --git a/libX11/modules/im/ximcp/imTransR.c b/libX11/modules/im/ximcp/imTransR.c
index caa530904..50b549e71 100644
--- a/libX11/modules/im/ximcp/imTransR.c
+++ b/libX11/modules/im/ximcp/imTransR.c
@@ -138,7 +138,7 @@ _XimReadData(
data_len -= i;
if (data_len) {
- if (!(tmp = (char *)Xmalloc(data_len))) {
+ if (!(tmp = Xmalloc(data_len))) {
return XIM_FALSE;
}
memcpy(tmp, &hold_buf[i], data_len);
@@ -173,7 +173,7 @@ _XimReadData(
}
if (packet_size > buf_size) {
- if (!(tmp = (char *)Xmalloc(data_len))) {
+ if (!(tmp = Xmalloc(data_len))) {
return XIM_FALSE;
}
memcpy(tmp, buf, data_len);
@@ -200,7 +200,7 @@ _XimReadData(
data_len -= i;
if (data_len) {
- if (!(tmp = (char *)Xmalloc(data_len))) {
+ if (!(tmp = Xmalloc(data_len))) {
return XIM_FALSE;
}
memcpy(tmp, &buf[i], data_len);
@@ -283,7 +283,7 @@ _XimFilterWaitEvent(Xim im)
preply = reply;
} else {
buf_size = (int)read_len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimReadData(im, &read_len, preply, buf_size);
if(ret_code != XIM_TRUE) {
if (preply != reply)