diff options
Diffstat (limited to 'libX11/modules')
24 files changed, 207 insertions, 176 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) diff --git a/libX11/modules/lc/def/lcDefConv.c b/libX11/modules/lc/def/lcDefConv.c index 12a48615e..3cd5c22c9 100644 --- a/libX11/modules/lc/def/lcDefConv.c +++ b/libX11/modules/lc/def/lcDefConv.c @@ -564,9 +564,9 @@ close_converter( XlcConv conv) { if (conv->state) - Xfree((char *) conv->state); + Xfree(conv->state); - Xfree((char *) conv); + Xfree(conv); } static XlcConv @@ -577,11 +577,11 @@ create_conv( XlcConv conv; State state; - conv = (XlcConv) Xcalloc(1, sizeof(XlcConvRec)); + conv = Xcalloc(1, sizeof(XlcConvRec)); if (conv == NULL) return (XlcConv) NULL; - state = (State) Xmalloc(sizeof(StateRec)); + state = Xmalloc(sizeof(StateRec)); if (state == NULL) { close_converter(conv); return (XlcConv) NULL; diff --git a/libX11/modules/lc/gen/lcGenConv.c b/libX11/modules/lc/gen/lcGenConv.c index 1041dc709..1f7c301f5 100644 --- a/libX11/modules/lc/gen/lcGenConv.c +++ b/libX11/modules/lc/gen/lcGenConv.c @@ -342,7 +342,7 @@ byteM_parse_codeset( continue; for (j = 0; j < codeset->length; j++) { - ch = *((unsigned char *)(inbufptr + j)); + ch = *((const unsigned char *)(inbufptr + j)); byteM_rec = byteM[j]; byteinfo = byteM_rec.byteinfo; @@ -1224,7 +1224,7 @@ stdc_wcstocts( ret: if (buf) - Xfree((char *)buf); + Xfree(buf); return (unconv_num1 + unconv_num2); } @@ -1544,7 +1544,7 @@ stdc_ctstowcs( ret: if (buf) - Xfree((char *)buf); + Xfree(buf); return (unconv_num1 + unconv_num2); } @@ -1580,7 +1580,7 @@ stdc_cstowcs( ret: if (buf) - Xfree((char *)buf); + Xfree(buf); return (unconv_num1 + unconv_num2); } @@ -1616,7 +1616,7 @@ mbstocts( ret: if (buf) - Xfree((char *)buf); + Xfree(buf); return (unconv_num1 + unconv_num2); } @@ -2063,7 +2063,7 @@ stdc_wcstostr( ret: if (buf) - Xfree((char *)buf); + Xfree(buf); return (unconv_num1 + unconv_num2); } @@ -2338,7 +2338,7 @@ ctstombs( ret: if (buf) - Xfree((char *)buf); + Xfree(buf); return (unconv_num1 + unconv_num2); } @@ -2374,7 +2374,7 @@ cstombs( ret: if (buf) - Xfree((char *)buf); + Xfree(buf); return (unconv_num1 + unconv_num2); } @@ -2583,7 +2583,7 @@ stdc_strtowcs( ret: if (buf) - Xfree((char *)buf); + Xfree(buf); return (unconv_num1 + unconv_num2); } @@ -2597,14 +2597,14 @@ close_converter( XlcConv conv) { if (conv->state) { - Xfree((char *) conv->state); + Xfree(conv->state); } if (conv->methods) { - Xfree((char *) conv->methods); + Xfree(conv->methods); } - Xfree((char *) conv); + Xfree(conv); } /* -------------------------------------------------------------------------- */ @@ -2619,11 +2619,11 @@ create_conv( XlcConv conv; State state; - conv = (XlcConv) Xcalloc(1, sizeof(XlcConvRec)); + conv = Xcalloc(1, sizeof(XlcConvRec)); if (conv == NULL) return (XlcConv) NULL; - conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec)); + conv->methods = Xmalloc(sizeof(XlcConvMethodsRec)); if (conv->methods == NULL) goto err; *conv->methods = *methods; diff --git a/libX11/modules/lc/xlocale/lcEuc.c b/libX11/modules/lc/xlocale/lcEuc.c index 442e3090f..5b171a9f3 100644 --- a/libX11/modules/lc/xlocale/lcEuc.c +++ b/libX11/modules/lc/xlocale/lcEuc.c @@ -671,7 +671,7 @@ create_conv( { XlcConv conv; - conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + conv = Xmalloc(sizeof(XlcConvRec)); if (conv == NULL) return (XlcConv) NULL; @@ -1363,7 +1363,7 @@ static void close_converter( XlcConv conv) { - Xfree((char *) conv); + Xfree(conv); } enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS, diff --git a/libX11/modules/lc/xlocale/lcJis.c b/libX11/modules/lc/xlocale/lcJis.c index 551862d9b..a6917cf9f 100644 --- a/libX11/modules/lc/xlocale/lcJis.c +++ b/libX11/modules/lc/xlocale/lcJis.c @@ -520,10 +520,10 @@ close_converter( XlcConv conv) { if (conv->state) { - Xfree((char *) conv->state); + Xfree(conv->state); } - Xfree((char *) conv); + Xfree(conv); } static XlcConv @@ -534,11 +534,11 @@ create_conv( XlcConv conv; State state; - conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + conv = Xmalloc(sizeof(XlcConvRec)); if (conv == NULL) return (XlcConv) NULL; - conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec)); + conv->methods = Xmalloc(sizeof(XlcConvMethodsRec)); if (conv->methods == NULL) goto err; *conv->methods = *methods; diff --git a/libX11/modules/lc/xlocale/lcSjis.c b/libX11/modules/lc/xlocale/lcSjis.c index 74dd033ec..ac945570a 100644 --- a/libX11/modules/lc/xlocale/lcSjis.c +++ b/libX11/modules/lc/xlocale/lcSjis.c @@ -1420,7 +1420,7 @@ static void close_converter( XlcConv conv) { - Xfree((char *) conv); + Xfree(conv); } @@ -1431,7 +1431,7 @@ create_conv( { XlcConv conv; - conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + conv = Xmalloc(sizeof(XlcConvRec)); if (conv == NULL) return (XlcConv) NULL; diff --git a/libX11/modules/om/generic/omGeneric.c b/libX11/modules/om/generic/omGeneric.c index ae43283ec..7122bb762 100644 --- a/libX11/modules/om/generic/omGeneric.c +++ b/libX11/modules/om/generic/omGeneric.c @@ -101,7 +101,7 @@ init_fontdata( FontData fd; int i; - fd = (FontData)Xmalloc(sizeof(FontDataRec) * font_data_count); + fd = Xmalloc(sizeof(FontDataRec) * font_data_count); if(fd == (FontData) NULL) return False; @@ -126,7 +126,7 @@ init_vrotate( if(type == VROTATE_NONE) return (VRotate)NULL; - vrotate = (VRotate)Xmalloc(sizeof(VRotateRec) * font_data_count); + vrotate = Xmalloc(sizeof(VRotateRec) * font_data_count); if(vrotate == (VRotate) NULL) return False; @@ -155,7 +155,7 @@ init_fontset( count = XOM_GENERIC(oc->core.om)->data_num; data = XOM_GENERIC(oc->core.om)->data; - font_set = (FontSet) Xmalloc(sizeof(FontSetRec) * count); + font_set = Xmalloc(sizeof(FontSetRec) * count); if (font_set == NULL) return False; memset((char *) font_set, 0x00, sizeof(FontSetRec) * count); @@ -463,15 +463,15 @@ init_core_part( if (count == 0) return False; - font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *) * count); + font_struct_list = Xmalloc(sizeof(XFontStruct *) * count); if (font_struct_list == NULL) return False; - font_name_list = (char **) Xmalloc(sizeof(char *) * count); + font_name_list = Xmalloc(sizeof(char *) * count); if (font_name_list == NULL) goto err; - font_name_buf = (char *) Xmalloc(length); + font_name_buf = Xmalloc(length); if (font_name_buf == NULL) goto err; @@ -585,7 +585,8 @@ get_rotate_fontname( } } pixel_size = atoi(fields[PIXEL_SIZE_FIELD - 1]); - sprintf(str_pixel, "[ 0 ~%d %d 0 ]", pixel_size, pixel_size); + snprintf(str_pixel, sizeof(str_pixel), + "[ 0 ~%d %d 0 ]", pixel_size, pixel_size); fields[6] = str_pixel; /* Point Size field : fields[7] */ @@ -602,7 +603,7 @@ get_rotate_fontname( if (len > XLFD_MAX_LEN) goto free_pattern; - rotate_font_ptr = (char *)Xmalloc(len + 1); + rotate_font_ptr = Xmalloc(len + 1); if(!rotate_font_ptr) goto free_pattern; @@ -1097,7 +1098,7 @@ parse_vw( Xfree(vrotate); if(sub_num > 0) { - vrotate = font_set->vrotate = (VRotate)Xmalloc + vrotate = font_set->vrotate = Xmalloc (sizeof(VRotateRec) * sub_num); if(font_set->vrotate == (VRotate)NULL) return (-1); @@ -1287,12 +1288,12 @@ set_missing_list( return True; } - charset_list = (char **) Xmalloc(sizeof(char *) * count); + charset_list = Xmalloc(sizeof(char *) * count); if (charset_list == NULL) { return False; } - charset_buf = (char *) Xmalloc(length); + charset_buf = Xmalloc(length); if (charset_buf == NULL) { Xfree(charset_list); return False; @@ -1868,9 +1869,9 @@ add_data( int num; if ((num = gen->data_num)) - new = (OMData) Xrealloc(gen->data, (num + 1) * sizeof(OMDataRec)); + new = Xrealloc(gen->data, (num + 1) * sizeof(OMDataRec)); else - new = (OMData) Xmalloc(sizeof(OMDataRec)); + new = Xmalloc(sizeof(OMDataRec)); if (new == NULL) return NULL; @@ -1909,7 +1910,7 @@ read_EncodingInfo( bufptr++ ; } else len = strlen(buf); - font_data->name = (char *) Xmalloc(len + 1); + font_data->name = Xmalloc(len + 1); if (font_data->name == NULL) { Xfree(font_data); return NULL; @@ -1960,7 +1961,7 @@ static void read_vw( char **value, buf[BUFSIZ]; int count; - sprintf(buf, "fs%d.font.vertical_map", num); + snprintf(buf, sizeof(buf), "fs%d.font.vertical_map", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if (count > 0){ _XlcDbg_printValue(buf,value,count); @@ -1968,7 +1969,7 @@ static void read_vw( font_set->vmap = read_EncodingInfo(count,value); } - sprintf(buf, "fs%d.font.vertical_rotate", num); + snprintf(buf, sizeof(buf), "fs%d.font.vertical_rotate", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if (count > 0){ _XlcDbg_printValue(buf,value,count); @@ -2004,11 +2005,11 @@ init_om( for (num = 0; ; num++) { - sprintf(buf, "fs%d.charset.name", num); + snprintf(buf, sizeof(buf), "fs%d.charset.name", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if( count < 1){ - sprintf(buf, "fs%d.charset", num); + snprintf(buf, sizeof(buf), "fs%d.charset", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if (count < 1) break; @@ -2018,7 +2019,7 @@ init_om( if (data == NULL) return False; - charset_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet) * count); + charset_list = Xmalloc(sizeof(XlcCharSet) * count); if (charset_list == NULL) return False; data->charset_list = charset_list; @@ -2027,12 +2028,12 @@ init_om( while (count-- > 0){ *charset_list++ = _XlcGetCharSet(*value++); } - sprintf(buf, "fs%d.charset.udc_area", num); + snprintf(buf, sizeof(buf), "fs%d.charset.udc_area", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if( count > 0){ UDCArea udc; int i,flag = 0; - udc = (UDCArea)Xmalloc(count * sizeof(UDCAreaRec)); + udc = Xmalloc(count * sizeof(UDCAreaRec)); if (udc == NULL) return False; for(i=0;i<count;i++){ @@ -2051,10 +2052,10 @@ init_om( } } - sprintf(buf, "fs%d.font.primary", num); + snprintf(buf, sizeof(buf), "fs%d.font.primary", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if (count < 1){ - sprintf(buf, "fs%d.font", num); + snprintf(buf, sizeof(buf), "fs%d.font", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if (count < 1) return False; @@ -2067,7 +2068,7 @@ init_om( data->font_data = font_data; data->font_data_count = count; - sprintf(buf, "fs%d.font.substitute", num); + snprintf(buf, sizeof(buf), "fs%d.font.substitute", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if (count > 0){ font_data = read_EncodingInfo(count,value); @@ -2076,7 +2077,7 @@ init_om( data->substitute = font_data; data->substitute_num = count; } else { - sprintf(buf, "fs%d.font", num); + snprintf(buf, sizeof(buf), "fs%d.font", num); _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); if (count < 1) { data->substitute = NULL; @@ -2092,7 +2093,7 @@ init_om( } /* required charset list */ - required_list = (char **) Xmalloc(sizeof(char *) * gen->data_num); + required_list = Xmalloc(sizeof(char *) * gen->data_num); if (required_list == NULL) return False; @@ -2103,7 +2104,7 @@ init_om( data = gen->data; if (count > 0) { - bufptr = (char *) Xmalloc(length); + bufptr = Xmalloc(length); if (bufptr == NULL) { Xfree(required_list); return False; @@ -2117,7 +2118,7 @@ init_om( } /* orientation list */ - orientation = (XOrientation *) Xmalloc(sizeof(XOrientation) * 2); + orientation = Xmalloc(sizeof(XOrientation) * 2); if (orientation == NULL) return False; |