summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-08-06 15:17:27 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-08-06 16:20:43 -0700
commit05ee465685aba409800523c6615392a867366818 (patch)
tree6fb35f10308bd937bf06bf4a0296730d8f67a69b
parentf84dcc7fef5e0842e6408f059c13d73975114ec4 (diff)
downloadxorg-lib-libXmu-05ee465685aba409800523c6615392a867366818.tar.gz
Remove unnnecessary casts from *alloc() and free() calls
These are not needed in C89 and later. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/CloseHook.c14
-rw-r--r--src/CrCmap.c12
-rw-r--r--src/CvtCache.c4
-rw-r--r--src/DisplayQue.c12
-rw-r--r--src/Distinct.c4
-rw-r--r--src/LocBitmap.c6
-rw-r--r--src/LookupCmap.c5
-rw-r--r--src/RdBitF.c2
-rw-r--r--src/Xct.c32
9 files changed, 43 insertions, 48 deletions
diff --git a/src/CloseHook.c b/src/CloseHook.c
index 3eb06ac..d45fc12 100644
--- a/src/CloseHook.c
+++ b/src/CloseHook.c
@@ -117,15 +117,15 @@ XmuAddCloseDisplayHook(Display *dpy, XmuCloseHookProc func, XPointer arg)
CallbackRec *cb;
/* allocate ahead of time so that we can fail atomically */
- cb = (CallbackRec *) malloc (sizeof (CallbackRec));
+ cb = malloc (sizeof (CallbackRec));
if (!cb) return ((XPointer) NULL);
de = _FindDisplayEntry (dpy, NULL);
if (!de) {
- if ((de = (DisplayEntry *) malloc (sizeof (DisplayEntry))) == NULL ||
+ if ((de = malloc (sizeof (DisplayEntry))) == NULL ||
!_MakeExtension (dpy, &de->extension)) {
- free ((char *) cb);
- if (de) free ((char *) de);
+ free (cb);
+ free (de);
return ((CloseHook) NULL);
}
de->dpy = dpy;
@@ -182,7 +182,7 @@ XmuRemoveCloseDisplayHook(Display *dpy, CloseHook handle,
prev->next = h->next;
}
if (de->end == h) de->end = prev;
- if (de->calling != h) free ((char *) h);
+ if (de->calling != h) free (h);
return True;
}
@@ -261,7 +261,7 @@ _DoCallbacks(Display *dpy, XExtCodes *codes)
de->calling = h; /* let remove know we'll free it */
(*(h->func)) (dpy, h->arg);
de->calling = NULL;
- free ((char *) h);
+ free (h);
h = nexth;
}
@@ -271,7 +271,7 @@ _DoCallbacks(Display *dpy, XExtCodes *codes)
} else {
prev->next = de->next;
}
- free ((char *) de);
+ free (de);
return 1;
}
diff --git a/src/CrCmap.c b/src/CrCmap.c
index b92601d..154aed9 100644
--- a/src/CrCmap.c
+++ b/src/CrCmap.c
@@ -218,13 +218,13 @@ readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
* cell, so that is why we do these slow gymnastics.
*/
- if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
- sizeof(unsigned long))) == NULL)
+ if ((pixels = calloc((unsigned) vinfo->colormap_size,
+ sizeof(unsigned long))) == NULL)
return 0;
if ((npixels = ROmap(dpy, colormap->colormap, pixels,
vinfo->colormap_size, ncolors)) == 0) {
- free((char *) pixels);
+ free(pixels);
return 0;
}
@@ -235,7 +235,7 @@ readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
/* can't find enough contiguous cells, give up */
XFreeColors(dpy, colormap->colormap, pixels, npixels,
(unsigned long) 0);
- free((char *) pixels);
+ free(pixels);
return 0;
}
colormap->base_pixel = pixels[first_index];
@@ -326,7 +326,7 @@ readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
&(pixels[first_index + ncolors]), remainder,
(unsigned long) 0);
- free((char *) pixels);
+ free(pixels);
return 1;
}
@@ -462,7 +462,7 @@ free_cells(Display *dpy, Colormap cmap, unsigned long pixels[],
*/
XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0);
- free((char *) pixels);
+ free(pixels);
}
diff --git a/src/CvtCache.c b/src/CvtCache.c
index 921b51a..0b1941f 100644
--- a/src/CvtCache.c
+++ b/src/CvtCache.c
@@ -106,7 +106,7 @@ _XmuCCLookupDisplay(Display *dpy)
*/
e = XmuDQLookupDisplay (dq, dpy); /* see if it's there */
if (!e) { /* else create it */
- XmuCvtCache *c = (XmuCvtCache *) malloc (sizeof (XmuCvtCache));
+ XmuCvtCache *c = malloc (sizeof (XmuCvtCache));
if (!c) return NULL;
/*
@@ -114,7 +114,7 @@ _XmuCCLookupDisplay(Display *dpy)
*/
e = XmuDQAddDisplay (dq, dpy, (XPointer) c);
if (!e) {
- free ((char *) c);
+ free (c);
return NULL;
}
diff --git a/src/DisplayQue.c b/src/DisplayQue.c
index 7eea9f2..197689e 100644
--- a/src/DisplayQue.c
+++ b/src/DisplayQue.c
@@ -52,7 +52,7 @@ XmuDQCreate(XmuCloseDisplayQueueProc closefunc,
XmuFreeDisplayQueueProc freefunc,
XPointer data)
{
- XmuDisplayQueue *q = (XmuDisplayQueue *) malloc (sizeof (XmuDisplayQueue));
+ XmuDisplayQueue *q = malloc (sizeof (XmuDisplayQueue));
if (q) {
q->nentries = 0;
q->head = q->tail = NULL;
@@ -77,10 +77,10 @@ XmuDQDestroy(XmuDisplayQueue *q, Bool docallbacks)
while (e) {
XmuDisplayQueueEntry *nexte = e->next;
if (docallbacks && q->closefunc) CallCloseCallback (q, e);
- free ((char *) e);
+ free (e);
e = nexte;
}
- free ((char *) q);
+ free (q);
return True;
}
@@ -109,12 +109,12 @@ XmuDQAddDisplay(XmuDisplayQueue *q, Display *dpy, XPointer data)
{
XmuDisplayQueueEntry *e;
- if (!(e = (XmuDisplayQueueEntry *) malloc (sizeof (XmuDisplayQueueEntry)))) {
+ if (!(e = malloc (sizeof (XmuDisplayQueueEntry)))) {
return NULL;
}
if (!(e->closehook = XmuAddCloseDisplayHook (dpy, _DQCloseDisplay,
(XPointer) q))) {
- free ((char *) e);
+ free (e);
return NULL;
}
@@ -155,7 +155,7 @@ XmuDQRemoveDisplay(XmuDisplayQueue *q, Display *dpy)
e->next->prev = e->prev; /* else splice out */
(void) XmuRemoveCloseDisplayHook (dpy, e->closehook,
_DQCloseDisplay, (XPointer) q);
- free ((char *) e);
+ free (e);
q->nentries--;
return True;
}
diff --git a/src/Distinct.c b/src/Distinct.c
index 9d31494..8c8bb5f 100644
--- a/src/Distinct.c
+++ b/src/Distinct.c
@@ -77,13 +77,13 @@ XmuDistinguishablePixels(Display *dpy, Colormap cmap,
for (j = i + 1; j < count; j++)
if (pixels[i] == pixels[j])
return False;
- defs = (XColor *) malloc (count * sizeof (XColor));
+ defs = malloc (count * sizeof (XColor));
if (!defs)
return False;
for (i = 0; i < count; i++)
defs[i].pixel = pixels[i];
XQueryColors (dpy, cmap, defs, count);
ret = XmuDistinguishableColors (defs, count);
- free ((char *) defs);
+ free (defs);
return ret;
}
diff --git a/src/LocBitmap.c b/src/LocBitmap.c
index 229d0fd..0c3bc84 100644
--- a/src/LocBitmap.c
+++ b/src/LocBitmap.c
@@ -221,9 +221,9 @@ split_path_string(register char *src)
for (dst = src; *dst; dst++) if (*dst == ':') nelems++;
/* get memory for everything */
- dst = (char *) malloc (dst - src + 1);
+ dst = malloc (dst - src + 1);
if (!dst) return NULL;
- elemlist = (char **) calloc ((nelems + 1), sizeof (char *));
+ elemlist = calloc ((nelems + 1), sizeof (char *));
if (!elemlist) {
free (dst);
return NULL;
@@ -256,6 +256,6 @@ _XmuStringToBitmapFreeCache(register XmuCvtCache *c)
if (c->string_to_bitmap.bitmapFilePath) {
if (c->string_to_bitmap.bitmapFilePath[0])
free (c->string_to_bitmap.bitmapFilePath[0]);
- free ((char *) (c->string_to_bitmap.bitmapFilePath));
+ free (c->string_to_bitmap.bitmapFilePath);
}
}
diff --git a/src/LookupCmap.c b/src/LookupCmap.c
index 4a52290..31b339a 100644
--- a/src/LookupCmap.c
+++ b/src/LookupCmap.c
@@ -242,8 +242,7 @@ lookup(Display *dpy, int screen, VisualID visualid, Atom property,
if (cnew) {
XStandardColormap *m, *maps;
- s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof
- (XStandardColormap)));
+ s = malloc((unsigned) ((count+1) * sizeof(XStandardColormap)));
for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
m->colormap = maps->colormap;
@@ -269,7 +268,7 @@ lookup(Display *dpy, int screen, VisualID visualid, Atom property,
m->killid = cnew->killid;
XSetRGBColormaps(dpy, win, s, ++count, property);
- free((char *) s);
+ free(s);
}
XFree((char *) stdcmaps);
return 0;
diff --git a/src/RdBitF.c b/src/RdBitF.c
index dbea542..51f6e2a 100644
--- a/src/RdBitF.c
+++ b/src/RdBitF.c
@@ -226,7 +226,7 @@ XmuReadBitmapData(FILE *fstream, unsigned int *width, unsigned int *height,
bytes_per_line = (ww+7)/8 + padding;
size = bytes_per_line * hh;
- data = (unsigned char *) Xmalloc ((unsigned int) size);
+ data = Xmalloc ((unsigned int) size);
if (!data)
RETURN (BitmapNoMemory);
diff --git a/src/Xct.c b/src/Xct.c
index 9ff8d3c..4ca64c5 100644
--- a/src/Xct.c
+++ b/src/Xct.c
@@ -303,16 +303,15 @@ HandleExtended(register XctData data, int c)
if ((!IsGL(*cp) && !IsGR(*cp)) || (*cp == 0x2a) || (*cp == 0x3f))
return 0;
}
- ptr = (XctString)malloc((unsigned)len + 1);
+ ptr = malloc(len + 1);
(void) memmove((char *)ptr, (char *)enc, len);
ptr[len] = 0x00;
priv->enc_count++;
if (priv->encodings)
- priv->encodings = (char **)realloc(
- (char *)priv->encodings,
- priv->enc_count * sizeof(char *));
+ priv->encodings = realloc(priv->encodings,
+ priv->enc_count * sizeof(char *));
else
- priv->encodings = (char **)malloc(sizeof(char *));
+ priv->encodings = malloc(sizeof(char *));
priv->encodings[i] = (char *)ptr;
}
data->encoding = priv->encodings[i];
@@ -329,10 +328,9 @@ ShiftGRToGL(register XctData data, int hasCdata)
if (data->item_length > priv->buf_count) {
priv->buf_count = data->item_length;
if (priv->itembuf)
- priv->itembuf = (XctString)realloc((char *)priv->itembuf,
- priv->buf_count);
+ priv->itembuf = realloc(priv->itembuf, priv->buf_count);
else
- priv->itembuf = (XctString)malloc(priv->buf_count);
+ priv->itembuf = malloc(priv->buf_count);
}
(void) memmove((char *)priv->itembuf, (char *)data->item,
data->item_length);
@@ -355,7 +353,7 @@ XctCreate(_Xconst unsigned char *string, int length, XctFlags flags)
register XctData data;
register XctPriv priv;
- data = (XctData)malloc(sizeof(struct _XctRec) + sizeof(struct _XctPriv));
+ data = malloc(sizeof(struct _XctRec) + sizeof(struct _XctPriv));
if (!data)
return data;
data->priv = priv = (XctPriv)(data + 1);
@@ -502,13 +500,11 @@ XctNextItem(register XctData data)
if (priv->dirsize < data->horz_depth) {
priv->dirsize += 10;
if (priv->dirstack)
- priv->dirstack = (XctHDirection *)
- realloc((char *)priv->dirstack,
+ priv->dirstack = realloc(priv->dirstack,
priv->dirsize *
sizeof(XctHDirection));
else
- priv->dirstack = (XctHDirection *)
- malloc(priv->dirsize *
+ priv->dirstack = malloc(priv->dirsize *
sizeof(XctHDirection));
}
priv->dirstack[data->horz_depth - 1] = data->horizontal;
@@ -671,14 +667,14 @@ XctFree(register XctData data)
register XctPriv priv = data->priv;
if (priv->dirstack)
- free((char *)priv->dirstack);
+ free(priv->dirstack);
if (data->flags & XctFreeString)
- free((char *)data->total_string);
+ free(data->total_string);
for (i = 0; i < priv->enc_count; i++)
free(priv->encodings[i]);
if (priv->encodings)
- free((char *)priv->encodings);
+ free(priv->encodings);
if (priv->itembuf)
- free((char *)priv->itembuf);
- free((char *)data);
+ free(priv->itembuf);
+ free(data);
}