Commit 39dd37d5 authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

Replace Xmalloc+memset pairs with Xcalloc calls

parent a402ed01
...@@ -184,16 +184,14 @@ _XDefaultOpenIM( ...@@ -184,16 +184,14 @@ _XDefaultOpenIM(
return((XIM)NULL); return((XIM)NULL);
} }
if ((im = Xmalloc(sizeof(StaticXIMRec))) == (StaticXIM)NULL) { if ((im = Xcalloc(1, sizeof(StaticXIMRec))) == (StaticXIM)NULL) {
return((XIM)NULL); return((XIM)NULL);
} }
if ((local_impart = Xmalloc(sizeof(XIMStaticXIMRec))) if ((local_impart = Xcalloc(1, sizeof(XIMStaticXIMRec)))
== (XIMStaticXIMRec *)NULL) { == (XIMStaticXIMRec *)NULL) {
Xfree(im); Xfree(im);
return((XIM)NULL); return((XIM)NULL);
} }
memset(im, 0, sizeof(StaticXIMRec));
memset(local_impart, 0, sizeof(XIMStaticXIMRec));
buf[0] = '\0'; buf[0] = '\0';
i = 0; i = 0;
...@@ -344,10 +342,9 @@ _CreateIC(XIM im, XIMArg *arg) ...@@ -344,10 +342,9 @@ _CreateIC(XIM im, XIMArg *arg)
{ {
XIC ic; XIC ic;
if ((ic = Xmalloc(sizeof(XICRec))) == (XIC)NULL) { if ((ic = Xcalloc(1, sizeof(XICRec))) == (XIC)NULL) {
return ((XIC)NULL); return ((XIC)NULL);
} }
memset(ic, 0, sizeof(XICRec));
ic->methods = (XICMethods)&local_ic_methods; ic->methods = (XICMethods)&local_ic_methods;
ic->core.im = im; ic->core.im = im;
......
...@@ -447,7 +447,7 @@ _XimWriteCachedDefaultTree( ...@@ -447,7 +447,7 @@ _XimWriteCachedDefaultTree(
+ XIM_CACHE_TREE_ALIGNMENT-1) & -XIM_CACHE_TREE_ALIGNMENT; + XIM_CACHE_TREE_ALIGNMENT-1) & -XIM_CACHE_TREE_ALIGNMENT;
DefTreeBase *b = &im->private.local.base; DefTreeBase *b = &im->private.local.base;
if (! b->tree && ! (b->tree = Xmalloc (sizeof(DefTree))) ) if (! b->tree && ! (b->tree = Xcalloc (1, sizeof(DefTree))) )
return; return;
if (! b->mb && ! (b->mb = Xmalloc (1)) ) if (! b->mb && ! (b->mb = Xmalloc (1)) )
return; return;
...@@ -457,13 +457,11 @@ _XimWriteCachedDefaultTree( ...@@ -457,13 +457,11 @@ _XimWriteCachedDefaultTree(
return; return;
/* First entry is always unused */ /* First entry is always unused */
memset (b->tree, 0, sizeof(DefTree));
b->mb[0] = 0; b->mb[0] = 0;
b->wc[0] = 0; b->wc[0] = 0;
b->utf8[0] = 0; b->utf8[0] = 0;
m = Xmalloc (msize); m = Xcalloc (1, msize);
memset (m, 0, msize);
m->id = XIM_CACHE_MAGIC; m->id = XIM_CACHE_MAGIC;
m->version = XIM_CACHE_VERSION; m->version = XIM_CACHE_VERSION;
m->top = im->private.local.top; m->top = im->private.local.top;
......
...@@ -101,11 +101,10 @@ init_fontdata( ...@@ -101,11 +101,10 @@ init_fontdata(
FontData fd; FontData fd;
int i; int i;
fd = Xmalloc(sizeof(FontDataRec) * font_data_count); fd = Xcalloc(font_data_count, sizeof(FontDataRec));
if(fd == (FontData) NULL) if(fd == (FontData) NULL)
return False; return False;
memset(fd, 0x00, sizeof(FontDataRec) * font_data_count);
for(i = 0 ; i < font_data_count ; i++) for(i = 0 ; i < font_data_count ; i++)
fd[i] = font_data[i]; fd[i] = font_data[i];
...@@ -126,11 +125,10 @@ init_vrotate( ...@@ -126,11 +125,10 @@ init_vrotate(
if(type == VROTATE_NONE) if(type == VROTATE_NONE)
return (VRotate)NULL; return (VRotate)NULL;
vrotate = Xmalloc(sizeof(VRotateRec) * font_data_count); vrotate = Xcalloc(font_data_count, sizeof(VRotateRec));
if(vrotate == (VRotate) NULL) if(vrotate == (VRotate) NULL)
return False; return False;
memset(vrotate, 0x00, sizeof(VRotateRec) * font_data_count);
for(i = 0 ; i < font_data_count ; i++) { for(i = 0 ; i < font_data_count ; i++) {
vrotate[i].charset_name = font_data[i].name; vrotate[i].charset_name = font_data[i].name;
vrotate[i].side = font_data[i].side; vrotate[i].side = font_data[i].side;
...@@ -155,10 +153,9 @@ init_fontset( ...@@ -155,10 +153,9 @@ init_fontset(
count = XOM_GENERIC(oc->core.om)->data_num; count = XOM_GENERIC(oc->core.om)->data_num;
data = XOM_GENERIC(oc->core.om)->data; data = XOM_GENERIC(oc->core.om)->data;
font_set = Xmalloc(sizeof(FontSetRec) * count); font_set = Xcalloc(count, sizeof(FontSetRec));
if (font_set == NULL) if (font_set == NULL)
return False; return False;
memset((char *) font_set, 0x00, sizeof(FontSetRec) * count);
gen = XOC_GENERIC(oc); gen = XOC_GENERIC(oc);
gen->font_set_num = count; gen->font_set_num = count;
...@@ -1094,11 +1091,10 @@ parse_vw( ...@@ -1094,11 +1091,10 @@ parse_vw(
Xfree(vrotate); Xfree(vrotate);
if(sub_num > 0) { if(sub_num > 0) {
vrotate = font_set->vrotate = Xmalloc vrotate = font_set->vrotate = Xcalloc(sub_num,
(sizeof(VRotateRec) * sub_num); sizeof(VRotateRec));
if(font_set->vrotate == (VRotate)NULL) if(font_set->vrotate == (VRotate)NULL)
return (-1); return (-1);
memset(font_set->vrotate, 0x00, sizeof(VRotateRec) * sub_num);
for(i = 0 ; i < sub_num ; i++) { for(i = 0 ; i < sub_num ; i++) {
vrotate[i].charset_name = font_set->substitute[i].name; vrotate[i].charset_name = font_set->substitute[i].name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment