|
1 From 995dd372e73fcec43fb65bd42ff5adb409765f66 Mon Sep 17 00:00:00 2001 |
|
2 From: Alan Coopersmith <[email protected]> |
|
3 Date: Thu, 7 Mar 2013 23:46:05 -0800 |
|
4 Subject: [PATCH:libX11 35/38] Remove more unnecessary casts from |
|
5 Xmalloc/calloc calls |
|
6 |
|
7 Signed-off-by: Alan Coopersmith <[email protected]> |
|
8 --- |
|
9 src/Context.c | 8 ++++---- |
|
10 src/CrGC.c | 2 +- |
|
11 src/Depths.c | 2 +- |
|
12 src/FSWrap.c | 6 +++--- |
|
13 src/Font.c | 12 ++++++------ |
|
14 src/GetAtomNm.c | 8 ++++---- |
|
15 src/GetHints.c | 9 ++++----- |
|
16 src/GetRGBCMap.c | 3 +-- |
|
17 src/ImUtil.c | 6 +++--- |
|
18 src/InitExt.c | 4 ++-- |
|
19 src/IntAtom.c | 6 +++--- |
|
20 src/KeyBind.c | 8 +++----- |
|
21 src/ModMap.c | 4 ++-- |
|
22 src/OpenDis.c | 21 +++++++-------------- |
|
23 src/PixFormats.c | 4 ++-- |
|
24 src/PolyReg.c | 13 +++++-------- |
|
25 src/PropAlloc.c | 9 ++++----- |
|
26 src/PutBEvent.c | 2 +- |
|
27 src/PutImage.c | 13 ++++++------- |
|
28 src/Quarks.c | 9 ++++----- |
|
29 src/RdBitF.c | 2 +- |
|
30 src/Region.c | 19 +++++++++---------- |
|
31 src/RegstFlt.c | 4 ++-- |
|
32 src/SetFPath.c | 2 +- |
|
33 src/SetHints.c | 6 +++--- |
|
34 src/StrToText.c | 2 +- |
|
35 src/TextToStr.c | 4 ++-- |
|
36 src/VisUtil.c | 8 +++----- |
|
37 src/WrBitF.c | 2 +- |
|
38 src/XlibInt.c | 20 +++++++++----------- |
|
39 src/Xrm.c | 20 +++++++++----------- |
|
40 src/locking.c | 8 ++++---- |
|
41 src/udcInf.c | 9 ++++----- |
|
42 33 files changed, 115 insertions(+), 140 deletions(-) |
|
43 |
|
44 diff --git a/src/Context.c b/src/Context.c |
|
45 index 79ae7d6..4bb465b 100644 |
|
46 --- a/src/Context.c |
|
47 +++ b/src/Context.c |
|
48 @@ -111,7 +111,7 @@ static void ResizeTable(DB db) |
|
49 otable = db->table; |
|
50 for (i = INITHASHMASK+1; (i + i) < db->numentries; ) |
|
51 i += i; |
|
52 - db->table = (TableEntry *) Xcalloc((unsigned)i, sizeof(TableEntry)); |
|
53 + db->table = Xcalloc(i, sizeof(TableEntry)); |
|
54 if (!db->table) { |
|
55 db->table = otable; |
|
56 return; |
|
57 @@ -180,11 +180,11 @@ int XSaveContext( |
|
58 UnlockDisplay(display); |
|
59 } |
|
60 if (!db) { |
|
61 - db = (DB) Xmalloc(sizeof(DBRec)); |
|
62 + db = Xmalloc(sizeof(DBRec)); |
|
63 if (!db) |
|
64 return XCNOMEM; |
|
65 db->mask = INITHASHMASK; |
|
66 - db->table = (TableEntry *)Xcalloc(db->mask + 1, sizeof(TableEntry)); |
|
67 + db->table = Xcalloc(db->mask + 1, sizeof(TableEntry)); |
|
68 if (!db->table) { |
|
69 Xfree((char *)db); |
|
70 return XCNOMEM; |
|
71 @@ -210,7 +210,7 @@ int XSaveContext( |
|
72 return 0; |
|
73 } |
|
74 } |
|
75 - entry = (TableEntry) Xmalloc(sizeof(TableEntryRec)); |
|
76 + entry = Xmalloc(sizeof(TableEntryRec)); |
|
77 if (!entry) |
|
78 return XCNOMEM; |
|
79 entry->rid = rid; |
|
80 diff --git a/src/CrGC.c b/src/CrGC.c |
|
81 index 11de94c..2d5f17c 100644 |
|
82 --- a/src/CrGC.c |
|
83 +++ b/src/CrGC.c |
|
84 @@ -72,7 +72,7 @@ GC XCreateGC ( |
|
85 register _XExtension *ext; |
|
86 |
|
87 LockDisplay(dpy); |
|
88 - if ((gc = (GC)Xmalloc (sizeof(struct _XGC))) == NULL) { |
|
89 + if ((gc = Xmalloc (sizeof(struct _XGC))) == NULL) { |
|
90 UnlockDisplay(dpy); |
|
91 SyncHandle(); |
|
92 return (NULL); |
|
93 diff --git a/src/Depths.c b/src/Depths.c |
|
94 index f49655c..a8b719d 100644 |
|
95 --- a/src/Depths.c |
|
96 +++ b/src/Depths.c |
|
97 @@ -49,7 +49,7 @@ int *XListDepths ( |
|
98 register Depth *dp; |
|
99 register int i; |
|
100 |
|
101 - depths = (int *) Xmalloc (count * sizeof(int)); |
|
102 + depths = Xmalloc (count * sizeof(int)); |
|
103 if (!depths) return NULL; |
|
104 for (i = 0, dp = scr->depths; i < count; i++, dp++) |
|
105 depths[i] = dp->depth; |
|
106 diff --git a/src/FSWrap.c b/src/FSWrap.c |
|
107 index 910e602..12d0406 100644 |
|
108 --- a/src/FSWrap.c |
|
109 +++ b/src/FSWrap.c |
|
110 @@ -112,7 +112,7 @@ _XParseBaseFontNameList( |
|
111 if (!*ptr) |
|
112 break; |
|
113 } |
|
114 - if (!(list = (char **) Xmalloc((unsigned)sizeof(char *) * (*num + 1)))) { |
|
115 + if (!(list = Xmalloc(sizeof(char *) * (*num + 1)))) { |
|
116 Xfree(psave); |
|
117 return (char **)NULL; |
|
118 } |
|
119 @@ -133,7 +133,7 @@ copy_string_list( |
|
120 if (string_list == NULL || list_count <= 0) |
|
121 return (char **) NULL; |
|
122 |
|
123 - string_list_ret = (char **) Xmalloc(sizeof(char *) * list_count); |
|
124 + string_list_ret = Xmalloc(sizeof(char *) * list_count); |
|
125 if (string_list_ret == NULL) |
|
126 return (char **) NULL; |
|
127 |
|
128 @@ -142,7 +142,7 @@ copy_string_list( |
|
129 for (length = 0; count-- > 0; list_src++) |
|
130 length += strlen(*list_src) + 1; |
|
131 |
|
132 - dst = (char *) Xmalloc(length); |
|
133 + dst = Xmalloc(length); |
|
134 if (dst == NULL) { |
|
135 Xfree(string_list_ret); |
|
136 return (char **) NULL; |
|
137 diff --git a/src/Font.c b/src/Font.c |
|
138 index 5dbdb29..3beb8a5 100644 |
|
139 --- a/src/Font.c |
|
140 +++ b/src/Font.c |
|
141 @@ -215,7 +215,7 @@ _XQueryFont ( |
|
142 DeqAsyncHandler(dpy, &async); |
|
143 reply_left = reply.length - |
|
144 ((SIZEOF(xQueryFontReply) - SIZEOF(xReply)) >> 2); |
|
145 - if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) { |
|
146 + if (! (fs = Xmalloc (sizeof (XFontStruct)))) { |
|
147 _XEatDataWords(dpy, reply_left); |
|
148 return (XFontStruct *)NULL; |
|
149 } |
|
150 @@ -323,7 +323,7 @@ _XF86BigfontCodes ( |
|
151 if (pData) |
|
152 return (XF86BigfontCodes *) pData->private_data; |
|
153 |
|
154 - pData = (XExtData *) Xmalloc(sizeof(XExtData) + sizeof(XF86BigfontCodes)); |
|
155 + pData = Xmalloc(sizeof(XExtData) + sizeof(XF86BigfontCodes)); |
|
156 if (!pData) { |
|
157 /* Out of luck. */ |
|
158 return (XF86BigfontCodes *) NULL; |
|
159 @@ -459,7 +459,7 @@ _XF86BigfontQueryFont ( |
|
160 DeqAsyncHandler(dpy, &async1); |
|
161 reply_left = reply.length - |
|
162 ((SIZEOF(xXF86BigfontQueryFontReply) - SIZEOF(xReply)) >> 2); |
|
163 - if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) { |
|
164 + if (! (fs = Xmalloc (sizeof (XFontStruct)))) { |
|
165 _XEatDataWords(dpy, reply_left); |
|
166 return (XFontStruct *)NULL; |
|
167 } |
|
168 @@ -521,14 +521,14 @@ _XF86BigfontQueryFont ( |
|
169 |
|
170 nbytes = reply.nUniqCharInfos * SIZEOF(xCharInfo) |
|
171 + (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16); |
|
172 - pUniqCI = (xCharInfo *) Xmalloc (nbytes); |
|
173 + pUniqCI = Xmalloc (nbytes); |
|
174 if (!pUniqCI) { |
|
175 if (fs->properties) Xfree((char *) fs->properties); |
|
176 Xfree((char *) fs); |
|
177 _XEatDataWords(dpy, reply_left); |
|
178 return (XFontStruct *)NULL; |
|
179 } |
|
180 - if (! (fs->per_char = (XCharStruct *) Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) { |
|
181 + if (! (fs->per_char = Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) { |
|
182 Xfree((char *) pUniqCI); |
|
183 if (fs->properties) Xfree((char *) fs->properties); |
|
184 Xfree((char *) fs); |
|
185 @@ -555,7 +555,7 @@ _XF86BigfontQueryFont ( |
|
186 XEDataObject fs_union; |
|
187 char *addr; |
|
188 |
|
189 - pData = (XExtData *) Xmalloc(sizeof(XExtData)); |
|
190 + pData = Xmalloc(sizeof(XExtData)); |
|
191 if (!pData) { |
|
192 if (fs->properties) Xfree((char *) fs->properties); |
|
193 Xfree((char *) fs); |
|
194 diff --git a/src/GetAtomNm.c b/src/GetAtomNm.c |
|
195 index 996f7eb..32de50d 100644 |
|
196 --- a/src/GetAtomNm.c |
|
197 +++ b/src/GetAtomNm.c |
|
198 @@ -46,7 +46,7 @@ char *_XGetAtomName( |
|
199 for (idx = TABLESIZE; --idx >= 0; ) { |
|
200 if ((e = *table++) && (e->atom == atom)) { |
|
201 idx = strlen(EntryName(e)) + 1; |
|
202 - if ((name = (char *)Xmalloc(idx))) |
|
203 + if ((name = Xmalloc(idx))) |
|
204 strcpy(name, EntryName(e)); |
|
205 return name; |
|
206 } |
|
207 @@ -73,7 +73,7 @@ char *XGetAtomName( |
|
208 SyncHandle(); |
|
209 return(NULL); |
|
210 } |
|
211 - if ((name = (char *) Xmalloc(rep.nameLength+1))) { |
|
212 + if ((name = Xmalloc(rep.nameLength + 1))) { |
|
213 _XReadPad(dpy, name, (long)rep.nameLength); |
|
214 name[rep.nameLength] = '\0'; |
|
215 _XUpdateAtomCache(dpy, name, atom, 0, -1, 0); |
|
216 @@ -124,7 +124,7 @@ Bool _XGetAtomNameHandler( |
|
217 _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len, |
|
218 (SIZEOF(xGetAtomNameReply) - SIZEOF(xReply)) >> 2, |
|
219 False); |
|
220 - state->names[state->idx] = (char *) Xmalloc(repl->nameLength+1); |
|
221 + state->names[state->idx] = Xmalloc(repl->nameLength + 1); |
|
222 _XGetAsyncData(dpy, state->names[state->idx], buf, len, |
|
223 SIZEOF(xGetAtomNameReply), repl->nameLength, |
|
224 repl->length << 2); |
|
225 @@ -170,7 +170,7 @@ XGetAtomNames ( |
|
226 } |
|
227 if (missed >= 0) { |
|
228 if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
|
229 - if ((names_return[missed] = (char *) Xmalloc(rep.nameLength+1))) { |
|
230 + if ((names_return[missed] = Xmalloc(rep.nameLength + 1))) { |
|
231 _XReadPad(dpy, names_return[missed], (long)rep.nameLength); |
|
232 names_return[missed][rep.nameLength] = '\0'; |
|
233 _XUpdateAtomCache(dpy, names_return[missed], atoms[missed], |
|
234 diff --git a/src/GetHints.c b/src/GetHints.c |
|
235 index 4800fe7..3c410d3 100644 |
|
236 --- a/src/GetHints.c |
|
237 +++ b/src/GetHints.c |
|
238 @@ -128,7 +128,7 @@ XWMHints *XGetWMHints ( |
|
239 return(NULL); |
|
240 } |
|
241 /* static copies not allowed in library, due to reentrancy constraint*/ |
|
242 - if ((hints = (XWMHints *) Xcalloc (1, (unsigned) sizeof(XWMHints)))) { |
|
243 + if ((hints = Xcalloc (1, sizeof(XWMHints)))) { |
|
244 hints->flags = prop->flags; |
|
245 hints->input = (prop->input ? True : False); |
|
246 hints->initial_state = cvtINT32toInt (prop->initialState); |
|
247 @@ -203,8 +203,7 @@ Status XGetIconSizes ( |
|
248 /* static copies not allowed in library, due to reentrancy constraint*/ |
|
249 |
|
250 nitems /= NumPropIconSizeElements; |
|
251 - if (! (hp = hints = (XIconSize *) |
|
252 - Xcalloc ((unsigned) nitems, (unsigned) sizeof(XIconSize)))) { |
|
253 + if (! (hp = hints = Xcalloc (nitems, sizeof(XIconSize)))) { |
|
254 if (prop) Xfree ((char *) prop); |
|
255 return 0; |
|
256 } |
|
257 @@ -317,14 +316,14 @@ XGetClassHint( |
|
258 |
|
259 if ( (actual_type == XA_STRING) && (actual_format == 8) ) { |
|
260 len_name = strlen((char *) data); |
|
261 - if (! (classhint->res_name = Xmalloc((unsigned) (len_name+1)))) { |
|
262 + if (! (classhint->res_name = Xmalloc(len_name + 1))) { |
|
263 Xfree((char *) data); |
|
264 return (0); |
|
265 } |
|
266 strcpy(classhint->res_name, (char *) data); |
|
267 if (len_name == nitems) len_name--; |
|
268 len_class = strlen((char *) (data+len_name+1)); |
|
269 - if (! (classhint->res_class = Xmalloc((unsigned) (len_class+1)))) { |
|
270 + if (! (classhint->res_class = Xmalloc(len_class + 1))) { |
|
271 Xfree(classhint->res_name); |
|
272 classhint->res_name = (char *) NULL; |
|
273 Xfree((char *) data); |
|
274 diff --git a/src/GetRGBCMap.c b/src/GetRGBCMap.c |
|
275 index 9e227a2..2f0b752 100644 |
|
276 --- a/src/GetRGBCMap.c |
|
277 +++ b/src/GetRGBCMap.c |
|
278 @@ -99,8 +99,7 @@ Status XGetRGBColormaps ( |
|
279 /* |
|
280 * allocate array |
|
281 */ |
|
282 - cmaps = (XStandardColormap *) Xmalloc (ncmaps * |
|
283 - sizeof (XStandardColormap)); |
|
284 + cmaps = Xmalloc (ncmaps * sizeof (XStandardColormap)); |
|
285 if (!cmaps) { |
|
286 if (data) Xfree ((char *) data); |
|
287 return False; |
|
288 diff --git a/src/ImUtil.c b/src/ImUtil.c |
|
289 index fa8d464..240a261 100644 |
|
290 --- a/src/ImUtil.c |
|
291 +++ b/src/ImUtil.c |
|
292 @@ -332,7 +332,7 @@ XImage *XCreateImage ( |
|
293 (xpad != 8 && xpad != 16 && xpad != 32) || |
|
294 offset < 0) |
|
295 return (XImage *) NULL; |
|
296 - if ((image = (XImage *) Xcalloc(1, (unsigned) sizeof(XImage))) == NULL) |
|
297 + if ((image = Xcalloc(1, sizeof(XImage))) == NULL) |
|
298 return (XImage *) NULL; |
|
299 |
|
300 image->width = width; |
|
301 @@ -842,7 +842,7 @@ static XImage *_XSubImage ( |
|
302 register unsigned long pixel; |
|
303 char *data; |
|
304 |
|
305 - if ((subimage = (XImage *) Xcalloc (1, sizeof (XImage))) == NULL) |
|
306 + if ((subimage = Xcalloc (1, sizeof (XImage))) == NULL) |
|
307 return (XImage *) NULL; |
|
308 subimage->width = width; |
|
309 subimage->height = height; |
|
310 @@ -868,7 +868,7 @@ static XImage *_XSubImage ( |
|
311 _XInitImageFuncPtrs (subimage); |
|
312 dsize = subimage->bytes_per_line * height; |
|
313 if (subimage->format == XYPixmap) dsize = dsize * subimage->depth; |
|
314 - if (((data = Xcalloc (1, (unsigned) dsize)) == NULL) && (dsize > 0)) { |
|
315 + if (((data = Xcalloc (1, dsize)) == NULL) && (dsize > 0)) { |
|
316 Xfree((char *) subimage); |
|
317 return (XImage *) NULL; |
|
318 } |
|
319 diff --git a/src/InitExt.c b/src/InitExt.c |
|
320 index 19515cc..75991bd 100644 |
|
321 --- a/src/InitExt.c |
|
322 +++ b/src/InitExt.c |
|
323 @@ -49,7 +49,7 @@ XExtCodes *XInitExtension ( |
|
324 &codes.first_error)) return (NULL); |
|
325 |
|
326 LockDisplay (dpy); |
|
327 - if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension))) || |
|
328 + if (! (ext = Xcalloc (1, sizeof (_XExtension))) || |
|
329 ! (ext->name = strdup(name))) { |
|
330 if (ext) Xfree((char *) ext); |
|
331 UnlockDisplay(dpy); |
|
332 @@ -71,7 +71,7 @@ XExtCodes *XAddExtension (Display *dpy) |
|
333 register _XExtension *ext; |
|
334 |
|
335 LockDisplay (dpy); |
|
336 - if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension)))) { |
|
337 + if (! (ext = Xcalloc (1, sizeof (_XExtension)))) { |
|
338 UnlockDisplay(dpy); |
|
339 return (XExtCodes *) NULL; |
|
340 } |
|
341 diff --git a/src/IntAtom.c b/src/IntAtom.c |
|
342 index 7a56258..25466ca 100644 |
|
343 --- a/src/IntAtom.c |
|
344 +++ b/src/IntAtom.c |
|
345 @@ -72,7 +72,7 @@ Atom _XInternAtom( |
|
346 |
|
347 /* look in the cache first */ |
|
348 if (!(atoms = dpy->atoms)) { |
|
349 - dpy->atoms = atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable)); |
|
350 + dpy->atoms = atoms = Xcalloc(1, sizeof(AtomTable)); |
|
351 dpy->free_funcs->atoms = _XFreeAtomTable; |
|
352 } |
|
353 sig = 0; |
|
354 @@ -127,7 +127,7 @@ _XUpdateAtomCache( |
|
355 |
|
356 if (!dpy->atoms) { |
|
357 if (idx < 0) { |
|
358 - dpy->atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable)); |
|
359 + dpy->atoms = Xcalloc(1, sizeof(AtomTable)); |
|
360 dpy->free_funcs->atoms = _XFreeAtomTable; |
|
361 } |
|
362 if (!dpy->atoms) |
|
363 @@ -147,7 +147,7 @@ _XUpdateAtomCache( |
|
364 } |
|
365 } |
|
366 } |
|
367 - e = (Entry)Xmalloc(sizeof(EntryRec) + n + 1); |
|
368 + e = Xmalloc(sizeof(EntryRec) + n + 1); |
|
369 if (e) { |
|
370 e->sig = sig; |
|
371 e->atom = atom; |
|
372 diff --git a/src/KeyBind.c b/src/KeyBind.c |
|
373 index f22feca..2110772 100644 |
|
374 --- a/src/KeyBind.c |
|
375 +++ b/src/KeyBind.c |
|
376 @@ -997,11 +997,9 @@ XRebindKeysym ( |
|
377 tmp = dpy->key_bindings; |
|
378 nb = sizeof(KeySym) * nm; |
|
379 |
|
380 - if ((! (p = (struct _XKeytrans *) Xcalloc( 1, sizeof(struct _XKeytrans)))) || |
|
381 - ((! (p->string = (char *) Xmalloc( (unsigned) nbytes))) && |
|
382 - (nbytes > 0)) || |
|
383 - ((! (p->modifiers = (KeySym *) Xmalloc( (unsigned) nb))) && |
|
384 - (nb > 0))) { |
|
385 + if ((! (p = Xcalloc( 1, sizeof(struct _XKeytrans)))) || |
|
386 + ((! (p->string = Xmalloc(nbytes))) && (nbytes > 0)) || |
|
387 + ((! (p->modifiers = Xmalloc(nb))) && (nb > 0))) { |
|
388 if (p) { |
|
389 if (p->string) Xfree(p->string); |
|
390 if (p->modifiers) Xfree((char *) p->modifiers); |
|
391 diff --git a/src/ModMap.c b/src/ModMap.c |
|
392 index 122ca80..5c5b426 100644 |
|
393 --- a/src/ModMap.c |
|
394 +++ b/src/ModMap.c |
|
395 @@ -97,11 +97,11 @@ XSetModifierMapping( |
|
396 XModifierKeymap * |
|
397 XNewModifiermap(int keyspermodifier) |
|
398 { |
|
399 - XModifierKeymap *res = (XModifierKeymap *) Xmalloc((sizeof (XModifierKeymap))); |
|
400 + XModifierKeymap *res = Xmalloc((sizeof (XModifierKeymap))); |
|
401 if (res) { |
|
402 res->max_keypermod = keyspermodifier; |
|
403 res->modifiermap = (keyspermodifier > 0 ? |
|
404 - (KeyCode *) Xmalloc((unsigned) (8 * keyspermodifier)) |
|
405 + Xmalloc(8 * keyspermodifier) |
|
406 : (KeyCode *) NULL); |
|
407 if (keyspermodifier && (res->modifiermap == NULL)) { |
|
408 Xfree((char *) res); |
|
409 diff --git a/src/OpenDis.c b/src/OpenDis.c |
|
410 index 0bf1b91..7318ad9 100644 |
|
411 --- a/src/OpenDis.c |
|
412 +++ b/src/OpenDis.c |
|
413 @@ -112,7 +112,7 @@ XOpenDisplay ( |
|
414 /* |
|
415 * Attempt to allocate a display structure. Return NULL if allocation fails. |
|
416 */ |
|
417 - if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) { |
|
418 + if ((dpy = Xcalloc(1, sizeof(Display))) == NULL) { |
|
419 return(NULL); |
|
420 } |
|
421 |
|
422 @@ -246,9 +246,7 @@ XOpenDisplay ( |
|
423 dpy->qlen = 0; |
|
424 |
|
425 /* Set up free-function record */ |
|
426 - if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1, |
|
427 - sizeof(_XFreeFuncRec))) |
|
428 - == NULL) { |
|
429 + if ((dpy->free_funcs = Xcalloc(1, sizeof(_XFreeFuncRec))) == NULL) { |
|
430 OutOfMemory (dpy); |
|
431 return(NULL); |
|
432 } |
|
433 @@ -316,7 +314,7 @@ XOpenDisplay ( |
|
434 return (NULL); |
|
435 } |
|
436 |
|
437 - dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1)); |
|
438 + dpy->vendor = Xmalloc(u.setup->nbytesVendor + 1); |
|
439 if (dpy->vendor == NULL) { |
|
440 OutOfMemory(dpy); |
|
441 return (NULL); |
|
442 @@ -342,9 +340,7 @@ XOpenDisplay ( |
|
443 /* |
|
444 * Now iterate down setup information..... |
|
445 */ |
|
446 - dpy->pixmap_format = |
|
447 - (ScreenFormat *)Xmalloc( |
|
448 - (unsigned) (dpy->nformats *sizeof(ScreenFormat))); |
|
449 + dpy->pixmap_format = Xmalloc(dpy->nformats * sizeof(ScreenFormat)); |
|
450 if (dpy->pixmap_format == NULL) { |
|
451 OutOfMemory (dpy); |
|
452 return(NULL); |
|
453 @@ -372,8 +368,7 @@ XOpenDisplay ( |
|
454 /* |
|
455 * next the Screen structures. |
|
456 */ |
|
457 - dpy->screens = |
|
458 - (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen)); |
|
459 + dpy->screens = Xmalloc(dpy->nscreens * sizeof(Screen)); |
|
460 if (dpy->screens == NULL) { |
|
461 OutOfMemory (dpy); |
|
462 return(NULL); |
|
463 @@ -415,8 +410,7 @@ XOpenDisplay ( |
|
464 /* |
|
465 * lets set up the depth structures. |
|
466 */ |
|
467 - sp->depths = (Depth *)Xmalloc( |
|
468 - (unsigned)sp->ndepths*sizeof(Depth)); |
|
469 + sp->depths = Xmalloc(sp->ndepths * sizeof(Depth)); |
|
470 if (sp->depths == NULL) { |
|
471 OutOfMemory (dpy); |
|
472 return(NULL); |
|
473 @@ -438,8 +432,7 @@ XOpenDisplay ( |
|
474 dp->nvisuals = u.dp->nVisuals; |
|
475 u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth); |
|
476 if (dp->nvisuals > 0) { |
|
477 - dp->visuals = |
|
478 - (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual)); |
|
479 + dp->visuals = Xmalloc(dp->nvisuals * sizeof(Visual)); |
|
480 if (dp->visuals == NULL) { |
|
481 OutOfMemory (dpy); |
|
482 return(NULL); |
|
483 diff --git a/src/PixFormats.c b/src/PixFormats.c |
|
484 index 8e4a100..6d9f64d 100644 |
|
485 --- a/src/PixFormats.c |
|
486 +++ b/src/PixFormats.c |
|
487 @@ -38,8 +38,8 @@ XPixmapFormatValues *XListPixmapFormats ( |
|
488 Display *dpy, |
|
489 int *count) /* RETURN */ |
|
490 { |
|
491 - XPixmapFormatValues *formats = (XPixmapFormatValues *) |
|
492 - Xmalloc((unsigned) (dpy->nformats * sizeof (XPixmapFormatValues))); |
|
493 + XPixmapFormatValues *formats = |
|
494 + Xmalloc(dpy->nformats * sizeof (XPixmapFormatValues)); |
|
495 |
|
496 if (formats) { |
|
497 register int i; |
|
498 diff --git a/src/PolyReg.c b/src/PolyReg.c |
|
499 index 74c8765..6d02773 100644 |
|
500 --- a/src/PolyReg.c |
|
501 +++ b/src/PolyReg.c |
|
502 @@ -95,8 +95,7 @@ InsertEdgeInET( |
|
503 { |
|
504 if (*iSLLBlock > SLLSPERBLOCK-1) |
|
505 { |
|
506 - tmpSLLBlock = |
|
507 - (ScanLineListBlock *)Xmalloc(sizeof(ScanLineListBlock)); |
|
508 + tmpSLLBlock = Xmalloc(sizeof(ScanLineListBlock)); |
|
509 (*SLLBlock)->next = tmpSLLBlock; |
|
510 tmpSLLBlock->next = (ScanLineListBlock *)NULL; |
|
511 *SLLBlock = tmpSLLBlock; |
|
512 @@ -410,8 +409,7 @@ static int PtsToRegion( |
|
513 |
|
514 numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1; |
|
515 |
|
516 - if (!(reg->rects = (BOX *)Xrealloc((char *)reg->rects, |
|
517 - (unsigned) (sizeof(BOX) * numRects)))) { |
|
518 + if (!(reg->rects = Xrealloc(reg->rects, sizeof(BOX) * numRects))) { |
|
519 Xfree(prevRects); |
|
520 return(0); |
|
521 } |
|
522 @@ -521,8 +519,7 @@ XPolygonRegion( |
|
523 |
|
524 if (Count < 2) return region; |
|
525 |
|
526 - if (! (pETEs = (EdgeTableEntry *) |
|
527 - Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count)))) { |
|
528 + if (! (pETEs = Xmalloc(sizeof(EdgeTableEntry) * Count))) { |
|
529 XDestroyRegion(region); |
|
530 return (Region) NULL; |
|
531 } |
|
532 @@ -559,7 +556,7 @@ XPolygonRegion( |
|
533 * send out the buffer |
|
534 */ |
|
535 if (iPts == NUMPTSTOBUFFER) { |
|
536 - tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK)); |
|
537 + tmpPtBlock = Xmalloc(sizeof(POINTBLOCK)); |
|
538 curPtBlock->next = tmpPtBlock; |
|
539 curPtBlock = tmpPtBlock; |
|
540 pts = curPtBlock->pts; |
|
541 @@ -605,7 +602,7 @@ XPolygonRegion( |
|
542 * send out the buffer |
|
543 */ |
|
544 if (iPts == NUMPTSTOBUFFER) { |
|
545 - tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK)); |
|
546 + tmpPtBlock = Xmalloc(sizeof(POINTBLOCK)); |
|
547 curPtBlock->next = tmpPtBlock; |
|
548 curPtBlock = tmpPtBlock; |
|
549 pts = curPtBlock->pts; |
|
550 diff --git a/src/PropAlloc.c b/src/PropAlloc.c |
|
551 index 5162830..87817d8 100644 |
|
552 --- a/src/PropAlloc.c |
|
553 +++ b/src/PropAlloc.c |
|
554 @@ -39,20 +39,19 @@ in this Software without prior written authorization from The Open Group. |
|
555 |
|
556 XSizeHints *XAllocSizeHints (void) |
|
557 { |
|
558 - return ((XSizeHints *) Xcalloc (1, (unsigned) sizeof (XSizeHints))); |
|
559 + return Xcalloc (1, sizeof (XSizeHints)); |
|
560 } |
|
561 |
|
562 |
|
563 XStandardColormap *XAllocStandardColormap (void) |
|
564 { |
|
565 - return ((XStandardColormap *) |
|
566 - Xcalloc (1, (unsigned) sizeof (XStandardColormap))); |
|
567 + return Xcalloc (1, sizeof (XStandardColormap)); |
|
568 } |
|
569 |
|
570 |
|
571 XWMHints *XAllocWMHints (void) |
|
572 { |
|
573 - return ((XWMHints *) Xcalloc (1, (unsigned) sizeof (XWMHints))); |
|
574 + return Xcalloc (1, sizeof (XWMHints)); |
|
575 } |
|
576 |
|
577 |
|
578 @@ -64,7 +63,7 @@ XClassHint *XAllocClassHint (void) |
|
579 |
|
580 XIconSize *XAllocIconSize (void) |
|
581 { |
|
582 - return ((XIconSize *) Xcalloc (1, (unsigned) sizeof (XIconSize))); |
|
583 + return Xcalloc (1, sizeof (XIconSize)); |
|
584 } |
|
585 |
|
586 |
|
587 diff --git a/src/PutBEvent.c b/src/PutBEvent.c |
|
588 index f9d4c29..1768e03 100644 |
|
589 --- a/src/PutBEvent.c |
|
590 +++ b/src/PutBEvent.c |
|
591 @@ -41,7 +41,7 @@ _XPutBackEvent ( |
|
592 XEvent store = *event; |
|
593 |
|
594 if (!dpy->qfree) { |
|
595 - if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) { |
|
596 + if ((dpy->qfree = Xmalloc (sizeof (_XQEvent))) == NULL) { |
|
597 return 0; |
|
598 } |
|
599 dpy->qfree->next = NULL; |
|
600 diff --git a/src/PutImage.c b/src/PutImage.c |
|
601 index 6dad4f1..2a694f0 100644 |
|
602 --- a/src/PutImage.c |
|
603 +++ b/src/PutImage.c |
|
604 @@ -680,7 +680,7 @@ SendXYImage( |
|
605 |
|
606 length = ROUNDUP(length, 4); |
|
607 if ((dpy->bufptr + length) > dpy->bufmax) { |
|
608 - if ((buf = _XAllocScratch(dpy, (unsigned long) (length))) == NULL) { |
|
609 + if ((buf = _XAllocScratch(dpy, length)) == NULL) { |
|
610 UnGetReq(PutImage); |
|
611 return; |
|
612 } |
|
613 @@ -703,13 +703,13 @@ SendXYImage( |
|
614 bytes_per_temp_plane = bytes_per_line * req->height; |
|
615 temp_length = ROUNDUP(bytes_per_temp_plane * image->depth, 4); |
|
616 if (buf == dpy->bufptr) { |
|
617 - if (! (temp = _XAllocScratch(dpy, (unsigned long) temp_length))) { |
|
618 + if (! (temp = _XAllocScratch(dpy, temp_length))) { |
|
619 UnGetReq(PutImage); |
|
620 return; |
|
621 } |
|
622 } |
|
623 else |
|
624 - if ((extra = temp = Xmalloc((unsigned) temp_length)) == NULL) { |
|
625 + if ((extra = temp = Xmalloc(temp_length)) == NULL) { |
|
626 UnGetReq(PutImage); |
|
627 return; |
|
628 } |
|
629 @@ -778,8 +778,7 @@ SendZImage( |
|
630 (req_yoffset * image->bytes_per_line) + |
|
631 ((req_xoffset * image->bits_per_pixel) >> 3); |
|
632 if ((image->bits_per_pixel == 4) && ((unsigned int) req_xoffset & 0x01)) { |
|
633 - if (! (shifted_src = (unsigned char *) |
|
634 - Xmalloc((unsigned) (req->height * image->bytes_per_line)))) { |
|
635 + if (! (shifted_src = Xmalloc(req->height * image->bytes_per_line))) { |
|
636 UnGetReq(PutImage); |
|
637 return; |
|
638 } |
|
639 @@ -810,7 +809,7 @@ SendZImage( |
|
640 dest = (unsigned char *)dpy->bufptr; |
|
641 else |
|
642 if ((dest = (unsigned char *) |
|
643 - _XAllocScratch(dpy, (unsigned long)(length))) == NULL) { |
|
644 + _XAllocScratch(dpy, length)) == NULL) { |
|
645 if (shifted_src) Xfree((char *) shifted_src); |
|
646 UnGetReq(PutImage); |
|
647 return; |
|
648 @@ -1001,7 +1000,7 @@ XPutImage ( |
|
649 img.bits_per_pixel = dest_bits_per_pixel; |
|
650 img.bytes_per_line = ROUNDUP((dest_bits_per_pixel * width), |
|
651 dest_scanline_pad) >> 3; |
|
652 - img.data = Xmalloc((unsigned) (img.bytes_per_line * height)); |
|
653 + img.data = Xmalloc(img.bytes_per_line * height); |
|
654 if (img.data == NULL) |
|
655 return 0; |
|
656 _XInitImageFuncPtrs(&img); |
|
657 diff --git a/src/Quarks.c b/src/Quarks.c |
|
658 index 4eb90c5..60fe127 100644 |
|
659 --- a/src/Quarks.c |
|
660 +++ b/src/Quarks.c |
|
661 @@ -186,15 +186,14 @@ ExpandQuarkTable(void) |
|
662 newmask = (oldmask << 1) + 1; |
|
663 else { |
|
664 if (!stringTable) { |
|
665 - stringTable = (XrmString **)Xmalloc(sizeof(XrmString *) * |
|
666 - CHUNKPER); |
|
667 + stringTable = Xmalloc(sizeof(XrmString *) * CHUNKPER); |
|
668 if (!stringTable) |
|
669 return False; |
|
670 stringTable[0] = (XrmString *)NULL; |
|
671 } |
|
672 #ifdef PERMQ |
|
673 if (!permTable) |
|
674 - permTable = (Bits **)Xmalloc(sizeof(Bits *) * CHUNKPER); |
|
675 + permTable = Xmalloc(sizeof(Bits *) * CHUNKPER); |
|
676 if (!permTable) |
|
677 return False; |
|
678 #endif |
|
679 @@ -289,13 +288,13 @@ nomatch: if (!rehash) |
|
680 q = nextQuark; |
|
681 if (!(q & QUANTUMMASK)) { |
|
682 if (!(q & CHUNKMASK)) { |
|
683 - if (!(new = Xrealloc((char *)stringTable, |
|
684 + if (!(new = Xrealloc(stringTable, |
|
685 sizeof(XrmString *) * |
|
686 ((q >> QUANTUMSHIFT) + CHUNKPER)))) |
|
687 goto fail; |
|
688 stringTable = (XrmString **)new; |
|
689 #ifdef PERMQ |
|
690 - if (!(new = Xrealloc((char *)permTable, |
|
691 + if (!(new = Xrealloc(permTable, |
|
692 sizeof(Bits *) * |
|
693 ((q >> QUANTUMSHIFT) + CHUNKPER)))) |
|
694 goto fail; |
|
695 diff --git a/src/RdBitF.c b/src/RdBitF.c |
|
696 index ab7d800..727204f 100644 |
|
697 --- a/src/RdBitF.c |
|
698 +++ b/src/RdBitF.c |
|
699 @@ -191,7 +191,7 @@ XReadBitmapFileData ( |
|
700 bytes_per_line = (ww+7)/8 + padding; |
|
701 |
|
702 size = bytes_per_line * hh; |
|
703 - bits = (unsigned char *) Xmalloc ((unsigned int) size); |
|
704 + bits = Xmalloc (size); |
|
705 if (!bits) |
|
706 RETURN (BitmapNoMemory); |
|
707 |
|
708 diff --git a/src/Region.c b/src/Region.c |
|
709 index 41047b2..d3d431a 100644 |
|
710 --- a/src/Region.c |
|
711 +++ b/src/Region.c |
|
712 @@ -139,9 +139,9 @@ XCreateRegion(void) |
|
713 { |
|
714 Region temp; |
|
715 |
|
716 - if (! (temp = ( Region )Xmalloc( (unsigned) sizeof( REGION )))) |
|
717 + if (! (temp = Xmalloc(sizeof( REGION )))) |
|
718 return (Region) NULL; |
|
719 - if (! (temp->rects = ( BOX * )Xmalloc( (unsigned) sizeof( BOX )))) { |
|
720 + if (! (temp->rects = Xmalloc(sizeof( BOX )))) { |
|
721 Xfree((char *) temp); |
|
722 return (Region) NULL; |
|
723 } |
|
724 @@ -521,9 +521,9 @@ miRegionCopy( |
|
725 { |
|
726 BOX *prevRects = dstrgn->rects; |
|
727 |
|
728 - if (! (dstrgn->rects = (BOX *) |
|
729 - Xrealloc((char *) dstrgn->rects, |
|
730 - (unsigned) rgn->numRects * (sizeof(BOX))))) { |
|
731 + dstrgn->rects = Xrealloc(dstrgn->rects, |
|
732 + rgn->numRects * (sizeof(BOX))); |
|
733 + if (! dstrgn->rects) { |
|
734 Xfree(prevRects); |
|
735 return; |
|
736 } |
|
737 @@ -788,8 +788,7 @@ miRegionOp( |
|
738 */ |
|
739 newReg->size = max(reg1->numRects,reg2->numRects) * 2; |
|
740 |
|
741 - if (! (newReg->rects = (BoxPtr) |
|
742 - Xmalloc ((unsigned) (sizeof(BoxRec) * newReg->size)))) { |
|
743 + if (! (newReg->rects = Xmalloc (sizeof(BoxRec) * newReg->size))) { |
|
744 newReg->size = 0; |
|
745 return; |
|
746 } |
|
747 @@ -980,8 +979,8 @@ miRegionOp( |
|
748 { |
|
749 BoxPtr prev_rects = newReg->rects; |
|
750 newReg->size = newReg->numRects; |
|
751 - newReg->rects = (BoxPtr) Xrealloc ((char *) newReg->rects, |
|
752 - (unsigned) (sizeof(BoxRec) * newReg->size)); |
|
753 + newReg->rects = Xrealloc (newReg->rects, |
|
754 + sizeof(BoxRec) * newReg->size); |
|
755 if (! newReg->rects) |
|
756 newReg->rects = prev_rects; |
|
757 } |
|
758 @@ -993,7 +992,7 @@ miRegionOp( |
|
759 */ |
|
760 newReg->size = 1; |
|
761 Xfree((char *) newReg->rects); |
|
762 - newReg->rects = (BoxPtr) Xmalloc(sizeof(BoxRec)); |
|
763 + newReg->rects = Xmalloc(sizeof(BoxRec)); |
|
764 } |
|
765 } |
|
766 Xfree ((char *) oldRects); |
|
767 diff --git a/src/RegstFlt.c b/src/RegstFlt.c |
|
768 index 9a560e7..5a1faa7 100644 |
|
769 --- a/src/RegstFlt.c |
|
770 +++ b/src/RegstFlt.c |
|
771 @@ -85,7 +85,7 @@ _XRegisterFilterByMask( |
|
772 { |
|
773 XFilterEventRec *rec; |
|
774 |
|
775 - rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec)); |
|
776 + rec = Xmalloc(sizeof(XFilterEventRec)); |
|
777 if (!rec) |
|
778 return; |
|
779 rec->window = window; |
|
780 @@ -117,7 +117,7 @@ _XRegisterFilterByType( |
|
781 { |
|
782 XFilterEventRec *rec; |
|
783 |
|
784 - rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec)); |
|
785 + rec = Xmalloc(sizeof(XFilterEventRec)); |
|
786 if (!rec) |
|
787 return; |
|
788 rec->window = window; |
|
789 diff --git a/src/SetFPath.c b/src/SetFPath.c |
|
790 index 89955c2..b1afd82 100644 |
|
791 --- a/src/SetFPath.c |
|
792 +++ b/src/SetFPath.c |
|
793 @@ -52,7 +52,7 @@ XSetFontPath ( |
|
794 } |
|
795 nbytes = (n + 3) & ~3; |
|
796 req->length += nbytes >> 2; |
|
797 - if ((p = (char *) Xmalloc ((unsigned) nbytes))) { |
|
798 + if ((p = Xmalloc (nbytes))) { |
|
799 /* |
|
800 * pack into counted strings. |
|
801 */ |
|
802 diff --git a/src/SetHints.c b/src/SetHints.c |
|
803 index 1cde48f..0ae0764 100644 |
|
804 --- a/src/SetHints.c |
|
805 +++ b/src/SetHints.c |
|
806 @@ -184,7 +184,7 @@ XSetIconSizes ( |
|
807 #define size_of_the_real_thing sizeof /* avoid grepping screwups */ |
|
808 unsigned nbytes = count * size_of_the_real_thing(xPropIconSize); |
|
809 #undef size_of_the_real_thing |
|
810 - if ((prop = pp = (xPropIconSize *) Xmalloc (nbytes))) { |
|
811 + if ((prop = pp = Xmalloc (nbytes))) { |
|
812 for (i = 0; i < count; i++) { |
|
813 pp->minWidth = list->min_width; |
|
814 pp->minHeight = list->min_height; |
|
815 @@ -216,7 +216,7 @@ XSetCommand ( |
|
816 for (i = 0, nbytes = 0; i < argc; i++) { |
|
817 nbytes += safestrlen(argv[i]) + 1; |
|
818 } |
|
819 - if ((bp = buf = Xmalloc((unsigned) nbytes))) { |
|
820 + if ((bp = buf = Xmalloc(nbytes))) { |
|
821 /* copy arguments into single buffer */ |
|
822 for (i = 0; i < argc; i++) { |
|
823 if (argv[i]) { |
|
824 @@ -299,7 +299,7 @@ XSetClassHint( |
|
825 |
|
826 len_nm = safestrlen(classhint->res_name); |
|
827 len_cl = safestrlen(classhint->res_class); |
|
828 - if ((class_string = s = Xmalloc((unsigned) (len_nm + len_cl + 2)))) { |
|
829 + if ((class_string = s = Xmalloc(len_nm + len_cl + 2))) { |
|
830 if (len_nm) { |
|
831 strcpy(s, classhint->res_name); |
|
832 s += len_nm + 1; |
|
833 diff --git a/src/StrToText.c b/src/StrToText.c |
|
834 index b5327e8..ef927f3 100644 |
|
835 --- a/src/StrToText.c |
|
836 +++ b/src/StrToText.c |
|
837 @@ -78,7 +78,7 @@ Status XStringListToTextProperty ( |
|
838 } |
|
839 } |
|
840 } else { |
|
841 - proto.value = (unsigned char *) Xmalloc (1); /* easier for client */ |
|
842 + proto.value = Xmalloc (1); /* easier for client */ |
|
843 if (!proto.value) return False; |
|
844 |
|
845 proto.value[0] = '\0'; |
|
846 diff --git a/src/TextToStr.c b/src/TextToStr.c |
|
847 index 216391c..36d9f07 100644 |
|
848 --- a/src/TextToStr.c |
|
849 +++ b/src/TextToStr.c |
|
850 @@ -72,10 +72,10 @@ Status XTextPropertyToStringList ( |
|
851 /* |
|
852 * allocate list and duplicate |
|
853 */ |
|
854 - list = (char **) Xmalloc (nelements * sizeof (char *)); |
|
855 + list = Xmalloc (nelements * sizeof (char *)); |
|
856 if (!list) return False; |
|
857 |
|
858 - start = (char *) Xmalloc ((datalen + 1) * sizeof (char)); /* for <NUL> */ |
|
859 + start = Xmalloc ((datalen + 1) * sizeof (char)); /* for <NUL> */ |
|
860 if (!start) { |
|
861 Xfree ((char *) list); |
|
862 return False; |
|
863 diff --git a/src/VisUtil.c b/src/VisUtil.c |
|
864 index 3434c01..aa67992 100644 |
|
865 --- a/src/VisUtil.c |
|
866 +++ b/src/VisUtil.c |
|
867 @@ -75,8 +75,7 @@ XVisualInfo *XGetVisualInfo( |
|
868 |
|
869 count = 0; |
|
870 total = 10; |
|
871 - if (! (vip_base = vip = (XVisualInfo *) |
|
872 - Xmalloc((unsigned) (sizeof(XVisualInfo) * total)))) { |
|
873 + if (! (vip_base = vip = Xmalloc(sizeof(XVisualInfo) * total))) { |
|
874 UnlockDisplay(dpy); |
|
875 return (XVisualInfo *) NULL; |
|
876 } |
|
877 @@ -132,9 +131,8 @@ XVisualInfo *XGetVisualInfo( |
|
878 { |
|
879 XVisualInfo *old_vip_base = vip_base; |
|
880 total += 10; |
|
881 - if (! (vip_base = (XVisualInfo *) |
|
882 - Xrealloc((char *) vip_base, |
|
883 - (unsigned) (sizeof(XVisualInfo) * total)))) { |
|
884 + if (! (vip_base = Xrealloc(vip_base, |
|
885 + sizeof(XVisualInfo) * total))) { |
|
886 Xfree((char *) old_vip_base); |
|
887 UnlockDisplay(dpy); |
|
888 return (XVisualInfo *) NULL; |
|
889 diff --git a/src/WrBitF.c b/src/WrBitF.c |
|
890 index 1ec6280..75a93a7 100644 |
|
891 --- a/src/WrBitF.c |
|
892 +++ b/src/WrBitF.c |
|
893 @@ -53,7 +53,7 @@ static char *Format_Image( |
|
894 bytes_per_line = (width+7)/8; |
|
895 *resultsize = bytes_per_line * height; /* Calculate size of data */ |
|
896 |
|
897 - data = (char *) Xmalloc( *resultsize ); /* Get space for data */ |
|
898 + data = Xmalloc( *resultsize ); /* Get space for data */ |
|
899 if (!data) |
|
900 return(ERR_RETURN); |
|
901 |
|
902 diff --git a/src/XlibInt.c b/src/XlibInt.c |
|
903 index 1c964fd..b06e57b 100644 |
|
904 --- a/src/XlibInt.c |
|
905 +++ b/src/XlibInt.c |
|
906 @@ -152,7 +152,7 @@ Bool _XPollfdCacheInit( |
|
907 #ifdef USE_POLL |
|
908 struct pollfd *pfp; |
|
909 |
|
910 - pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd)); |
|
911 + pfp = Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd)); |
|
912 if (!pfp) |
|
913 return False; |
|
914 pfp[0].fd = dpy->fd; |
|
915 @@ -374,10 +374,10 @@ _XRegisterInternalConnection( |
|
916 struct _XConnWatchInfo *watchers; |
|
917 XPointer *wd; |
|
918 |
|
919 - new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo)); |
|
920 + new_conni = Xmalloc(sizeof(struct _XConnectionInfo)); |
|
921 if (!new_conni) |
|
922 return 0; |
|
923 - new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer)); |
|
924 + new_conni->watch_data = Xmalloc(dpy->watcher_count * sizeof(XPointer)); |
|
925 if (!new_conni->watch_data) { |
|
926 Xfree(new_conni); |
|
927 return 0; |
|
928 @@ -464,7 +464,7 @@ XInternalConnectionNumbers( |
|
929 count = 0; |
|
930 for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) |
|
931 count++; |
|
932 - fd_list = (int*) Xmalloc (count * sizeof(int)); |
|
933 + fd_list = Xmalloc (count * sizeof(int)); |
|
934 if (!fd_list) { |
|
935 UnlockDisplay(dpy); |
|
936 return 0; |
|
937 @@ -537,9 +537,8 @@ XAddConnectionWatch( |
|
938 |
|
939 /* allocate new watch data */ |
|
940 for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { |
|
941 - wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data, |
|
942 - (dpy->watcher_count + 1) * |
|
943 - sizeof(XPointer)); |
|
944 + wd_array = Xrealloc(info_list->watch_data, |
|
945 + (dpy->watcher_count + 1) * sizeof(XPointer)); |
|
946 if (!wd_array) { |
|
947 UnlockDisplay(dpy); |
|
948 return 0; |
|
949 @@ -548,7 +547,7 @@ XAddConnectionWatch( |
|
950 wd_array[dpy->watcher_count] = NULL; /* for cleanliness */ |
|
951 } |
|
952 |
|
953 - new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo)); |
|
954 + new_watcher = Xmalloc(sizeof(struct _XConnWatchInfo)); |
|
955 if (!new_watcher) { |
|
956 UnlockDisplay(dpy); |
|
957 return 0; |
|
958 @@ -756,8 +755,7 @@ void _XEnq( |
|
959 /* If dpy->qfree is non-NULL do this, else malloc a new one. */ |
|
960 dpy->qfree = qelt->next; |
|
961 } |
|
962 - else if ((qelt = |
|
963 - (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) { |
|
964 + else if ((qelt = Xmalloc(sizeof(_XQEvent))) == NULL) { |
|
965 /* Malloc call failed! */ |
|
966 ESET(ENOMEM); |
|
967 _XIOError(dpy); |
|
968 @@ -1518,7 +1516,7 @@ char *_XAllocScratch( |
|
969 { |
|
970 if (nbytes > dpy->scratch_length) { |
|
971 if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer); |
|
972 - if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes))) |
|
973 + if ((dpy->scratch_buffer = Xmalloc(nbytes))) |
|
974 dpy->scratch_length = nbytes; |
|
975 else dpy->scratch_length = 0; |
|
976 } |
|
977 diff --git a/src/Xrm.c b/src/Xrm.c |
|
978 index 2c0c324..d8272ee 100644 |
|
979 --- a/src/Xrm.c |
|
980 +++ b/src/Xrm.c |
|
981 @@ -495,7 +495,7 @@ static XrmDatabase NewDatabase(void) |
|
982 { |
|
983 register XrmDatabase db; |
|
984 |
|
985 - db = (XrmDatabase) Xmalloc(sizeof(XrmHashBucketRec)); |
|
986 + db = Xmalloc(sizeof(XrmHashBucketRec)); |
|
987 if (db) { |
|
988 _XCreateMutex(&db->linfo); |
|
989 db->table = (NTable)NULL; |
|
990 @@ -828,7 +828,7 @@ static void PutEntry( |
|
991 NTable *nprev, *firstpprev; |
|
992 |
|
993 #define NEWTABLE(q,i) \ |
|
994 - table = (NTable)Xmalloc(sizeof(LTableRec)); \ |
|
995 + table = Xmalloc(sizeof(LTableRec)); \ |
|
996 if (!table) \ |
|
997 return; \ |
|
998 table->name = q; \ |
|
999 @@ -841,7 +841,7 @@ static void PutEntry( |
|
1000 nprev = NodeBuckets(table); \ |
|
1001 } else { \ |
|
1002 table->leaf = 1; \ |
|
1003 - if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) {\ |
|
1004 + if (!(nprev = Xmalloc(sizeof(VEntry *)))) {\ |
|
1005 Xfree(table); \ |
|
1006 return; \ |
|
1007 } \ |
|
1008 @@ -955,9 +955,8 @@ static void PutEntry( |
|
1009 prev = nprev; |
|
1010 } |
|
1011 /* now allocate the value entry */ |
|
1012 - entry = (VEntry)Xmalloc(((type == XrmQString) ? |
|
1013 - sizeof(VEntryRec) : sizeof(DEntryRec)) + |
|
1014 - value->size); |
|
1015 + entry = Xmalloc(((type == XrmQString) ? |
|
1016 + sizeof(VEntryRec) : sizeof(DEntryRec)) + value->size); |
|
1017 if (!entry) |
|
1018 return; |
|
1019 entry->name = q = *quarks; |
|
1020 @@ -987,13 +986,12 @@ static void PutEntry( |
|
1021 if (resourceQuarks) { |
|
1022 unsigned char *prevQuarks = resourceQuarks; |
|
1023 |
|
1024 - resourceQuarks = (unsigned char *)Xrealloc((char *)resourceQuarks, |
|
1025 - size); |
|
1026 + resourceQuarks = Xrealloc(resourceQuarks, size); |
|
1027 if (!resourceQuarks) { |
|
1028 Xfree(prevQuarks); |
|
1029 } |
|
1030 } else |
|
1031 - resourceQuarks = (unsigned char *)Xmalloc(size); |
|
1032 + resourceQuarks = Xmalloc(size); |
|
1033 if (resourceQuarks) { |
|
1034 bzero((char *)&resourceQuarks[oldsize], size - oldsize); |
|
1035 maxResourceQuark = (size << 3) - 1; |
|
1036 @@ -1138,11 +1136,11 @@ static void GetDatabase( |
|
1037 |
|
1038 str_len = strlen (str); |
|
1039 if (DEF_BUFF_SIZE > str_len) lhs = lhs_s; |
|
1040 - else if ((lhs = (char*) Xmalloc (str_len)) == NULL) |
|
1041 + else if ((lhs = Xmalloc (str_len)) == NULL) |
|
1042 return; |
|
1043 |
|
1044 alloc_chars = DEF_BUFF_SIZE < str_len ? str_len : DEF_BUFF_SIZE; |
|
1045 - if ((rhs = (char*) Xmalloc (alloc_chars)) == NULL) { |
|
1046 + if ((rhs = Xmalloc (alloc_chars)) == NULL) { |
|
1047 if (lhs != lhs_s) Xfree (lhs); |
|
1048 return; |
|
1049 } |
|
1050 diff --git a/src/locking.c b/src/locking.c |
|
1051 index b3dfb3b..7c09c44 100644 |
|
1052 --- a/src/locking.c |
|
1053 +++ b/src/locking.c |
|
1054 @@ -82,7 +82,7 @@ _Xthread_waiter(void) |
|
1055 struct _xthread_waiter *me; |
|
1056 |
|
1057 if (!(me = TlsGetValue(_X_TlsIndex))) { |
|
1058 - me = (struct _xthread_waiter *)xmalloc(sizeof(struct _xthread_waiter)); |
|
1059 + me = xmalloc(sizeof(struct _xthread_waiter)); |
|
1060 me->sem = CreateSemaphore(NULL, 0, 1, NULL); |
|
1061 me->next = NULL; |
|
1062 TlsSetValue(_X_TlsIndex, me); |
|
1063 @@ -249,7 +249,7 @@ static struct _XCVList *_XCreateCVL( |
|
1064 dpy->lock->free_cvls = cvl->next; |
|
1065 dpy->lock->num_free_cvls--; |
|
1066 } else { |
|
1067 - cvl = (struct _XCVList *)Xmalloc(sizeof(struct _XCVList)); |
|
1068 + cvl = Xmalloc(sizeof(struct _XCVList)); |
|
1069 if (!cvl) |
|
1070 return NULL; |
|
1071 cvl->cv = xcondition_malloc(); |
|
1072 @@ -512,10 +512,10 @@ void _XUserUnlockDisplay( |
|
1073 static int _XInitDisplayLock( |
|
1074 Display *dpy) |
|
1075 { |
|
1076 - dpy->lock_fns = (struct _XLockPtrs*)Xmalloc(sizeof(struct _XLockPtrs)); |
|
1077 + dpy->lock_fns = Xmalloc(sizeof(struct _XLockPtrs)); |
|
1078 if (dpy->lock_fns == NULL) |
|
1079 return -1; |
|
1080 - dpy->lock = (struct _XLockInfo *)Xmalloc(sizeof(struct _XLockInfo)); |
|
1081 + dpy->lock = Xmalloc(sizeof(struct _XLockInfo)); |
|
1082 if (dpy->lock == NULL) { |
|
1083 _XFreeDisplayLock(dpy); |
|
1084 return -1; |
|
1085 diff --git a/src/udcInf.c b/src/udcInf.c |
|
1086 index b7577ac..9ecf156 100644 |
|
1087 --- a/src/udcInf.c |
|
1088 +++ b/src/udcInf.c |
|
1089 @@ -145,12 +145,11 @@ int *num_codeset; |
|
1090 if(!_XlcCompareISOLatin1(charset_str,buf)){ |
|
1091 num_ret += 1; |
|
1092 if(num_ret == 1){ |
|
1093 - ret = (int *)Xmalloc(sizeof(int)); |
|
1094 + ret = Xmalloc(sizeof(int)); |
|
1095 } else { |
|
1096 int *prev_ret = ret; |
|
1097 |
|
1098 - ret = |
|
1099 - (int *)Xrealloc(ret,num_ret*sizeof(int)); |
|
1100 + ret = Xrealloc(ret, num_ret * sizeof(int)); |
|
1101 if (ret == NULL){ |
|
1102 Xfree(prev_ret); |
|
1103 } |
|
1104 @@ -272,7 +271,7 @@ int *num_gr; |
|
1105 sprintf(buf, "fs%d.charset.udc_area", codeset-1); |
|
1106 _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); |
|
1107 if(count > 0){ |
|
1108 - udc = (_XUDCGlyphRegion *)Xmalloc(count * sizeof(_XUDCGlyphRegion)); |
|
1109 + udc = Xmalloc(count * sizeof(_XUDCGlyphRegion)); |
|
1110 if(udc == NULL){ |
|
1111 _xudc_utyerrno = 0x03 ; |
|
1112 _xudc_utyerrno |= (0x0b<<8) ; |
|
1113 @@ -524,7 +523,7 @@ int *num_cr; |
|
1114 return(ret); |
|
1115 } |
|
1116 |
|
1117 - crr = (_XUDCCodeRegion *)Xmalloc(num_gr*sizeof(_XUDCCodeRegion)); |
|
1118 + crr = Xmalloc(num_gr * sizeof(_XUDCCodeRegion)); |
|
1119 if(crr == NULL){ |
|
1120 Xfree(gr); |
|
1121 _xudc_utyerrno = 0x03 ; |
|
1122 -- |
|
1123 1.7.9.2 |
|
1124 |
|
1125 From 993349bf944ad312b0dd7096558fb8cfe1eff16b Mon Sep 17 00:00:00 2001 |
|
1126 From: Alan Coopersmith <[email protected]> |
|
1127 Date: Sat, 16 Mar 2013 10:03:13 -0700 |
|
1128 Subject: [PATCH:libX11 36/38] Use calloc in XOpenDisplay to initialize |
|
1129 structs containing pointers |
|
1130 |
|
1131 Prevents trying to free uninitialized pointers if we have to bail out |
|
1132 partway through setup, such as if we receive a corrupted or incomplete |
|
1133 connection setup block from the server. |
|
1134 |
|
1135 Signed-off-by: Alan Coopersmith <[email protected]> |
|
1136 --- |
|
1137 src/OpenDis.c | 8 ++++---- |
|
1138 1 file changed, 4 insertions(+), 4 deletions(-) |
|
1139 |
|
1140 diff --git a/src/OpenDis.c b/src/OpenDis.c |
|
1141 index 7318ad9..fc67d1a 100644 |
|
1142 --- a/src/OpenDis.c |
|
1143 +++ b/src/OpenDis.c |
|
1144 @@ -340,7 +340,7 @@ XOpenDisplay ( |
|
1145 /* |
|
1146 * Now iterate down setup information..... |
|
1147 */ |
|
1148 - dpy->pixmap_format = Xmalloc(dpy->nformats * sizeof(ScreenFormat)); |
|
1149 + dpy->pixmap_format = Xcalloc(dpy->nformats, sizeof(ScreenFormat)); |
|
1150 if (dpy->pixmap_format == NULL) { |
|
1151 OutOfMemory (dpy); |
|
1152 return(NULL); |
|
1153 @@ -368,7 +368,7 @@ XOpenDisplay ( |
|
1154 /* |
|
1155 * next the Screen structures. |
|
1156 */ |
|
1157 - dpy->screens = Xmalloc(dpy->nscreens * sizeof(Screen)); |
|
1158 + dpy->screens = Xcalloc(dpy->nscreens, sizeof(Screen)); |
|
1159 if (dpy->screens == NULL) { |
|
1160 OutOfMemory (dpy); |
|
1161 return(NULL); |
|
1162 @@ -410,7 +410,7 @@ XOpenDisplay ( |
|
1163 /* |
|
1164 * lets set up the depth structures. |
|
1165 */ |
|
1166 - sp->depths = Xmalloc(sp->ndepths * sizeof(Depth)); |
|
1167 + sp->depths = Xcalloc(sp->ndepths, sizeof(Depth)); |
|
1168 if (sp->depths == NULL) { |
|
1169 OutOfMemory (dpy); |
|
1170 return(NULL); |
|
1171 @@ -432,7 +432,7 @@ XOpenDisplay ( |
|
1172 dp->nvisuals = u.dp->nVisuals; |
|
1173 u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth); |
|
1174 if (dp->nvisuals > 0) { |
|
1175 - dp->visuals = Xmalloc(dp->nvisuals * sizeof(Visual)); |
|
1176 + dp->visuals = Xcalloc(dp->nvisuals, sizeof(Visual)); |
|
1177 if (dp->visuals == NULL) { |
|
1178 OutOfMemory (dpy); |
|
1179 return(NULL); |
|
1180 -- |
|
1181 1.7.9.2 |
|
1182 |