diff options
| author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-04-12 21:27:45 -0700 |
|---|---|---|
| committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-04-18 17:49:13 -0700 |
| commit | 09194042d3dc44a463add1f7c122a68ffd5ef0bf (patch) | |
| tree | c8d2014664ca7c819caf231e0c4ef5c037e1b884 | |
| parent | ac1e2bff7121987fd768500a11d428d9fb9447c5 (diff) | |
Replace Xmalloc+bzero pairs with Xcalloc calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
| -rw-r--r-- | modules/im/ximcp/imDefIc.c | 3 | ||||
| -rw-r--r-- | modules/im/ximcp/imInt.c | 3 | ||||
| -rw-r--r-- | modules/im/ximcp/imLcIc.c | 3 | ||||
| -rw-r--r-- | modules/im/ximcp/imRm.c | 18 | ||||
| -rw-r--r-- | modules/im/ximcp/imRmAttr.c | 15 | ||||
| -rw-r--r-- | modules/im/ximcp/imThaiIc.c | 3 | ||||
| -rw-r--r-- | modules/im/ximcp/imTrX.c | 3 | ||||
| -rw-r--r-- | modules/im/ximcp/imTrans.c | 4 | ||||
| -rw-r--r-- | modules/lc/gen/lcGenConv.c | 3 | ||||
| -rw-r--r-- | modules/lc/xlocale/lcJis.c | 3 | ||||
| -rw-r--r-- | modules/om/generic/omGeneric.c | 9 | ||||
| -rw-r--r-- | src/Quarks.c | 3 | ||||
| -rw-r--r-- | src/Xrm.c | 6 | ||||
| -rw-r--r-- | src/xlibi18n/XDefaultOMIF.c | 16 | ||||
| -rw-r--r-- | src/xlibi18n/lcCharSet.c | 3 | ||||
| -rw-r--r-- | src/xlibi18n/lcDB.c | 6 | ||||
| -rw-r--r-- | src/xlibi18n/lcGeneric.c | 15 | ||||
| -rw-r--r-- | src/xlibi18n/lcPublic.c | 6 |
18 files changed, 39 insertions, 83 deletions
diff --git a/modules/im/ximcp/imDefIc.c b/modules/im/ximcp/imDefIc.c index 9283c49c..a962c1b0 100644 --- a/modules/im/ximcp/imDefIc.c +++ b/modules/im/ximcp/imDefIc.c @@ -1425,10 +1425,9 @@ _XimProtoCreateIC( if (!(_XimGetInputStyle(arg, &input_style))) return (XIC)NULL; - if ((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) + if ((ic = Xcalloc(1, sizeof(XicRec))) == (Xic)NULL) return (XIC)NULL; - bzero((char *)ic, sizeof(XicRec)); ic->methods = &ic_methods; ic->core.im = (XIM)im; ic->core.input_style = input_style; diff --git a/modules/im/ximcp/imInt.c b/modules/im/ximcp/imInt.c index b1980923..449a42de 100644 --- a/modules/im/ximcp/imInt.c +++ b/modules/im/ximcp/imInt.c @@ -204,9 +204,8 @@ _XimOpenIM( Xim im; register int i; - if (!(im = (Xim)Xmalloc(sizeof(XimRec)))) + if (!(im = Xcalloc(1, sizeof(XimRec)))) return (XIM)NULL; - bzero(im, sizeof(XimRec)); im->core.lcd = lcd; im->core.ic_chain = (XIC)NULL; diff --git a/modules/im/ximcp/imLcIc.c b/modules/im/ximcp/imLcIc.c index c0728084..49338853 100644 --- a/modules/im/ximcp/imLcIc.c +++ b/modules/im/ximcp/imLcIc.c @@ -143,10 +143,9 @@ _XimLocalCreateIC( unsigned int num; int len; - if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) { + if((ic = Xcalloc(1, sizeof(XicRec))) == (Xic)NULL) { return ((XIC)NULL); } - bzero((char *)ic, sizeof(XicRec)); ic->methods = &Local_ic_methods; ic->core.im = im; diff --git a/modules/im/ximcp/imRm.c b/modules/im/ximcp/imRm.c index 3d09b813..3449f91e 100644 --- a/modules/im/ximcp/imRm.c +++ b/modules/im/ximcp/imRm.c @@ -360,10 +360,9 @@ _XimDefaultStyles( n = XIMNumber(supported_local_styles) - 1; len = sizeof(XIMStyles) + sizeof(XIMStyle) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); styles = (XIMStyles *)tmp; if (n > 0) { @@ -396,10 +395,9 @@ _XimDefaultIMValues( n = XIMNumber(supported_local_im_values_list); len = sizeof(XIMValuesList) + sizeof(char **) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); values_list = (XIMValuesList *)tmp; if (n > 0) { @@ -433,10 +431,9 @@ _XimDefaultICValues( n = XIMNumber(supported_local_ic_values_list); len = sizeof(XIMValuesList) + sizeof(char **) * n; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); values_list = (XIMValuesList *)tmp; if (n > 0) { @@ -1085,10 +1082,9 @@ _XimDecodeStyles( num = styles->count_styles; len = sizeof(XIMStyles) + sizeof(XIMStyle) * num; - if(!(tmp = (XPointer)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); out = (XIMStyles *)tmp; if(num >0) { @@ -1124,10 +1120,9 @@ _XimDecodeValues( num = values_list->count_values; len = sizeof(XIMValuesList) + sizeof(char **) * num; - if(!(tmp = (char *)Xmalloc(len))) { + if(!(tmp = Xcalloc(1, len))) { return False; } - bzero(tmp, len); out = (XIMValuesList *)tmp; if(num) { @@ -2143,10 +2138,9 @@ _XimSetResourceList( XIMResourceList res; len = sizeof(XIMResource) * num_resource; - if(!(res = (XIMResourceList)Xmalloc(len))) { + if(!(res = Xcalloc(1, len))) { return False; } - bzero((char *)res, len); for(i = 0; i < num_resource; i++, id++) { res[i] = resource[i]; diff --git a/modules/im/ximcp/imRmAttr.c b/modules/im/ximcp/imRmAttr.c index 27dcbc9c..2e732658 100644 --- a/modules/im/ximcp/imRmAttr.c +++ b/modules/im/ximcp/imRmAttr.c @@ -1408,7 +1408,6 @@ _XimGetAttributeID( { unsigned int n; XIMResourceList res; - int res_len; char *names; int names_len; XPointer tmp; @@ -1426,18 +1425,15 @@ _XimGetAttributeID( if (!(n = _XimCountNumberOfAttr(buf[0], &buf[1], &names_len))) return False; - res_len = sizeof(XIMResource) * n; - if (!(res = (XIMResourceList)Xmalloc(res_len))) + if (!(res = Xcalloc(n, sizeof(XIMResource)))) return False; - bzero((char *)res, res_len); values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len; - if (!(tmp = (XPointer)Xmalloc(values_len))) { + if (!(tmp = Xcalloc(1, values_len))) { Xfree(res); return False; } - bzero(tmp, values_len); values_list = (XIMValuesList *)tmp; values = (char **)((char *)tmp + sizeof(XIMValuesList)); @@ -1475,18 +1471,15 @@ _XimGetAttributeID( if (!(n = _XimCountNumberOfAttr(buf[0], &buf[2], &names_len))) return False; - res_len = sizeof(XIMResource) * n; - if (!(res = (XIMResourceList)Xmalloc(res_len))) + if (!(res = Xcalloc(n, sizeof(XIMResource)))) return False; - bzero((char *)res, res_len); values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len; - if (!(tmp = (XPointer)Xmalloc(values_len))) { + if (!(tmp = Xcalloc(1, values_len))) { Xfree(res); return False; } - bzero(tmp, values_len); values_list = (XIMValuesList *)tmp; values = (char **)((char *)tmp + sizeof(XIMValuesList)); diff --git a/modules/im/ximcp/imThaiIc.c b/modules/im/ximcp/imThaiIc.c index d1cb22a5..95433f3d 100644 --- a/modules/im/ximcp/imThaiIc.c +++ b/modules/im/ximcp/imThaiIc.c @@ -157,10 +157,9 @@ _XimThaiCreateIC( int len; DefTree *tree; - if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) { + if((ic = Xcalloc(1, sizeof(XicRec))) == (Xic)NULL) { return ((XIC)NULL); } - bzero((char *)ic, sizeof(XicRec)); ic->methods = &Thai_ic_methods; ic->core.im = im; diff --git a/modules/im/ximcp/imTrX.c b/modules/im/ximcp/imTrX.c index edcaf085..d85d1d11 100644 --- a/modules/im/ximcp/imTrX.c +++ b/modules/im/ximcp/imTrX.c @@ -496,9 +496,8 @@ _XimXConf(Xim im, char *address) { XSpecRec *spec; - if (!(spec = (XSpecRec *)Xmalloc(sizeof(XSpecRec)))) + if (!(spec = Xcalloc(1, sizeof(XSpecRec)))) return False; - bzero(spec, sizeof(XSpecRec)); spec->improtocolid = XInternAtom(im->core.display, _XIM_PROTOCOL, False); spec->imconnectid = XInternAtom(im->core.display, _XIM_XCONNECT, False); diff --git a/modules/im/ximcp/imTrans.c b/modules/im/ximcp/imTrans.c index dfef7659..e321d590 100644 --- a/modules/im/ximcp/imTrans.c +++ b/modules/im/ximcp/imTrans.c @@ -293,13 +293,11 @@ _XimTransConf( if (!(paddr = (char *)Xmalloc(strlen(address) + 1))) return False; - if (!(spec = (TransSpecRec *) Xmalloc(sizeof(TransSpecRec)))) { + if (!(spec = Xcalloc(1, sizeof(TransSpecRec)))) { Xfree(paddr); return False; } - bzero(spec, sizeof(TransSpecRec)); - (void)strcpy(paddr, address); spec->address = paddr; diff --git a/modules/lc/gen/lcGenConv.c b/modules/lc/gen/lcGenConv.c index baac73a3..7a113a78 100644 --- a/modules/lc/gen/lcGenConv.c +++ b/modules/lc/gen/lcGenConv.c @@ -2660,10 +2660,9 @@ create_conv( *conv->methods = *methods; conv->methods->reset = init_state; - conv->state = (XPointer) Xmalloc(sizeof(StateRec)); + conv->state = Xcalloc(1, sizeof(StateRec)); if (conv->state == NULL) goto err; - bzero((char *) conv->state, sizeof(StateRec)); state = (State) conv->state; state->lcd = lcd; diff --git a/modules/lc/xlocale/lcJis.c b/modules/lc/xlocale/lcJis.c index 594e6363..551862d9 100644 --- a/modules/lc/xlocale/lcJis.c +++ b/modules/lc/xlocale/lcJis.c @@ -545,10 +545,9 @@ create_conv( if (XLC_PUBLIC(lcd, is_state_depend)) conv->methods->reset = init_state; - conv->state = (XPointer) Xmalloc(sizeof(StateRec)); + conv->state = Xcalloc(1, sizeof(StateRec)); if (conv->state == NULL) goto err; - bzero((char *) conv->state, sizeof(StateRec)); state = (State) conv->state; state->lcd = lcd; diff --git a/modules/om/generic/omGeneric.c b/modules/om/generic/omGeneric.c index 44143ac2..e3587966 100644 --- a/modules/om/generic/omGeneric.c +++ b/modules/om/generic/omGeneric.c @@ -1654,10 +1654,9 @@ create_oc( XOCMethodsList methods_list = oc_methods_list; int count; - oc = (XOC) Xmalloc(sizeof(XOCGenericRec)); + oc = Xcalloc(1, sizeof(XOCGenericRec)); if (oc == NULL) return (XOC) NULL; - bzero((char *) oc, sizeof(XOCGenericRec)); oc->core.om = om; @@ -1842,10 +1841,9 @@ create_om( { XOM om; - om = (XOM) Xmalloc(sizeof(XOMGenericRec)); + om = Xcalloc(1, sizeof(XOMGenericRec)); if (om == NULL) return (XOM) NULL; - bzero((char *) om, sizeof(XOMGenericRec)); om->methods = &methods; om->core.lcd = lcd; @@ -1913,10 +1911,9 @@ read_EncodingInfo( FontData font_data,ret; char *buf, *bufptr,*scp; int len; - font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count); + font_data = Xcalloc(count, sizeof(FontDataRec)); if (font_data == NULL) return NULL; - bzero((char *) font_data, sizeof(FontDataRec) * count); ret = font_data; for ( ; count-- > 0; font_data++) { diff --git a/src/Quarks.c b/src/Quarks.c index d0eb6901..7a704b10 100644 --- a/src/Quarks.c +++ b/src/Quarks.c @@ -210,10 +210,9 @@ ExpandQuarkTable(void) #endif newmask = 0x1ff; } - entries = (Entry *)Xmalloc(sizeof(Entry) * (newmask + 1)); + entries = Xcalloc(newmask + 1, sizeof(Entry)); if (!entries) return False; - bzero((char *)entries, sizeof(Entry) * (newmask + 1)); quarkTable = entries; quarkMask = newmask; quarkRehash = quarkMask - 2; @@ -581,23 +581,21 @@ static void GrowTable( ltable = (LTable)table; /* cons up a copy to make MoveValues look symmetric */ otable = *ltable; - ltable->buckets = (VEntry *)Xmalloc(i * sizeof(VEntry)); + ltable->buckets = Xcalloc(i, sizeof(VEntry)); if (!ltable->buckets) { ltable->buckets = otable.buckets; return; } ltable->table.mask = i - 1; - bzero((char *)ltable->buckets, i * sizeof(VEntry)); MoveValues(&otable, ltable); } else { register NTable ntable; - ntable = (NTable)Xmalloc(sizeof(NTableRec) + i * sizeof(NTable)); + ntable = Xcalloc(1, sizeof(NTableRec) + (i * sizeof(NTable))); if (!ntable) return; *ntable = *table; ntable->mask = i - 1; - bzero((char *)NodeBuckets(ntable), i * sizeof(NTable)); *prev = ntable; MoveTables(table, ntable); } diff --git a/src/xlibi18n/XDefaultOMIF.c b/src/xlibi18n/XDefaultOMIF.c index ae8ac79e..85d63e82 100644 --- a/src/xlibi18n/XDefaultOMIF.c +++ b/src/xlibi18n/XDefaultOMIF.c @@ -128,10 +128,9 @@ init_fontset( data = XOM_GENERIC(oc->core.om)->data; - font_set = (FontSet) Xmalloc(sizeof(FontSetRec)); + font_set = Xcalloc(1, sizeof(FontSetRec)); if (font_set == NULL) return False; - bzero((char *) font_set, sizeof(FontSetRec)); gen = XOC_GENERIC(oc); gen->font_set = font_set; @@ -1005,10 +1004,9 @@ create_oc( { XOC oc; - oc = (XOC) Xmalloc(sizeof(XOCGenericRec)); + oc = Xcalloc(1, sizeof(XOCGenericRec)); if (oc == NULL) return (XOC) NULL; - bzero((char *) oc, sizeof(XOCGenericRec)); oc->core.om = om; @@ -1126,15 +1124,13 @@ add_data( XOMGenericPart *gen = XOM_GENERIC(om); OMData new; - new = (OMData) Xmalloc(sizeof(OMDataRec)); + new = Xcalloc(1, sizeof(OMDataRec)); if (new == NULL) return NULL; gen->data = new; - bzero((char *) new, sizeof(OMDataRec)); - return new; } @@ -1168,10 +1164,9 @@ init_om( if (data == NULL) return False; - font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count); + font_data = Xcalloc(count, sizeof(FontDataRec)); if (font_data == NULL) return False; - bzero((char *) font_data, sizeof(FontDataRec) * count); data->font_data = font_data; data->font_data_count = count; @@ -1237,10 +1232,9 @@ _XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb, { XOM om; - om = (XOM) Xmalloc(sizeof(XOMGenericRec)); + om = Xcalloc(1, sizeof(XOMGenericRec)); if (om == NULL) return (XOM) NULL; - bzero((char *) om, sizeof(XOMGenericRec)); om->methods = (XOMMethods)&methods; om->core.lcd = lcd; diff --git a/src/xlibi18n/lcCharSet.c b/src/xlibi18n/lcCharSet.c index 0fa39d86..5d287811 100644 --- a/src/xlibi18n/lcCharSet.c +++ b/src/xlibi18n/lcCharSet.c @@ -176,10 +176,9 @@ _XlcCreateDefaultCharSet( const char *colon; char *tmp; - charset = (XlcCharSet) Xmalloc(sizeof(XlcCharSetRec)); + charset = Xcalloc(1, sizeof(XlcCharSetRec)); if (charset == NULL) return (XlcCharSet) NULL; - bzero((char *) charset, sizeof(XlcCharSetRec)); name_len = strlen(name); ct_sequence_len = strlen(ct_sequence); diff --git a/src/xlibi18n/lcDB.c b/src/xlibi18n/lcDB.c index afff1745..c6eb7f06 100644 --- a/src/xlibi18n/lcDB.c +++ b/src/xlibi18n/lcDB.c @@ -591,11 +591,10 @@ store_to_database( goto err; } - new = (Database)Xmalloc(sizeof(DatabaseRec)); + new = Xcalloc(1, sizeof(DatabaseRec)); if (new == (Database)NULL) { goto err; } - bzero(new, sizeof(DatabaseRec)); new->category = (char *)Xmalloc(strlen(parse_info.category) + 1); if (new->category == NULL) { @@ -1309,10 +1308,9 @@ _XlcCreateLocaleDataBase( return (XPointer)NULL; } n = CountDatabase(database); - lc_db = (XlcDatabase)Xmalloc(sizeof(XlcDatabaseRec) * (n + 1)); + lc_db = Xcalloc(n + 1, sizeof(XlcDatabaseRec)); if (lc_db == (XlcDatabase)NULL) goto err; - bzero(lc_db, sizeof(XlcDatabaseRec) * (n + 1)); for (p = database, i = 0; p && i < n; p = p->next, ++i) { lc_db[i].category_q = XrmStringToQuark(p->category); lc_db[i].name_q = XrmStringToQuark(p->name); diff --git a/src/xlibi18n/lcGeneric.c b/src/xlibi18n/lcGeneric.c index 688a4cfc..df392e9a 100644 --- a/src/xlibi18n/lcGeneric.c +++ b/src/xlibi18n/lcGeneric.c @@ -60,15 +60,13 @@ create( XLCd lcd; XLCdPublicMethods new; - lcd = (XLCd) Xmalloc(sizeof(XLCdRec)); + lcd = Xcalloc(1, sizeof(XLCdRec)); if (lcd == NULL) return (XLCd) NULL; - bzero((char *) lcd, sizeof(XLCdRec)); - lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdGenericRec)); + lcd->core = Xcalloc(1, sizeof(XLCdGenericRec)); if (lcd->core == NULL) goto err; - bzero((char *) lcd->core, sizeof(XLCdGenericRec)); new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec)); if (new == NULL) @@ -180,10 +178,9 @@ add_codeset( CodeSet new, *new_list; int num; - new = (CodeSet) Xmalloc(sizeof(CodeSetRec)); + new = Xcalloc(1, sizeof(CodeSetRec)); if (new == NULL) return NULL; - bzero((char *) new, sizeof(CodeSetRec)); if ((num = gen->codeset_num)) new_list = (CodeSet *) Xrealloc(gen->codeset_list, @@ -223,16 +220,14 @@ add_parse_list( return False; strcpy(str, encoding); - new = (ParseInfo) Xmalloc(sizeof(ParseInfoRec)); + new = Xcalloc(1, sizeof(ParseInfoRec)); if (new == NULL) goto err; - bzero((char *) new, sizeof(ParseInfoRec)); if (gen->mb_parse_table == NULL) { - gen->mb_parse_table = (unsigned char *) Xmalloc(256); /* 2^8 */ + gen->mb_parse_table = Xcalloc(1, 256); /* 2^8 */ if (gen->mb_parse_table == NULL) goto err; - bzero((char *) gen->mb_parse_table, 256); } if ((num = gen->mb_parse_list_num)) diff --git a/src/xlibi18n/lcPublic.c b/src/xlibi18n/lcPublic.c index 2c02f5fb..43b9286e 100644 --- a/src/xlibi18n/lcPublic.c +++ b/src/xlibi18n/lcPublic.c @@ -80,15 +80,13 @@ create( XLCd lcd; XLCdPublicMethods new; - lcd = (XLCd) Xmalloc(sizeof(XLCdRec)); + lcd = Xcalloc(1, sizeof(XLCdRec)); if (lcd == NULL) return (XLCd) NULL; - bzero((char *) lcd, sizeof(XLCdRec)); - lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdPublicRec)); + lcd->core = Xcalloc(1, sizeof(XLCdPublicRec)); if (lcd->core == NULL) goto err; - bzero((char *) lcd->core, sizeof(XLCdPublicRec)); new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec)); if (new == NULL) |
