diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-06-10 15:44:45 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-06-10 15:44:45 -0700 |
commit | ace42fef753c1444cfc208da6bb282abbbc279ab (patch) | |
tree | c1770abaaf8997a097a3d8ce88ef980706fe640b /src | |
parent | f12be5ac59a48249c77b8e61e78bceb9ad782542 (diff) |
Remove unnecessary casts of malloc/calloc results
These aren't needed in C89 and later, but can hide missing prototypes
that generate broken code on platforms where pointers are larger than ints.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/XEVI.c | 4 | ||||
-rw-r--r-- | src/XMultibuf.c | 4 | ||||
-rw-r--r-- | src/XSecurity.c | 2 | ||||
-rw-r--r-- | src/XShm.c | 2 | ||||
-rw-r--r-- | src/Xcup.c | 2 | ||||
-rw-r--r-- | src/Xdbe.c | 3 | ||||
-rw-r--r-- | src/Xge.c | 6 | ||||
-rw-r--r-- | src/extutil.c | 5 |
8 files changed, 13 insertions, 15 deletions
@@ -126,7 +126,7 @@ Status XeviGetVisualInfo( return BadValue; } if (!n_visual || !visual) { /* copy the all visual */ - temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * sz_info); + temp_visual = Xmalloc(sz_VisualID32 * sz_info); n_visual = 0; for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid)) @@ -146,7 +146,7 @@ Status XeviGetVisualInfo( return BadValue; } } - temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * n_visual); + temp_visual = Xmalloc(sz_VisualID32 * n_visual); for (visualIndex = 0; visualIndex < n_visual; visualIndex++) temp_visual[visualIndex] = visual[visualIndex]; } diff --git a/src/XMultibuf.c b/src/XMultibuf.c index 79034da..b2cab33 100644 --- a/src/XMultibuf.c +++ b/src/XMultibuf.c @@ -177,7 +177,7 @@ static Status event_to_wire (Display *dpy, XEvent *libevent, xEvent *netevent) * read_buffer_info - read Buffer Info descriptors from the net; if unable * to allocate memory, read junk to make sure that stream is clear. */ -#define TALLOC(type,count) ((type *) Xmalloc ((unsigned) count * sizeof(type))) +#define TALLOC(type,count) Xmalloc ((unsigned) count * sizeof(type)) static XmbufBufferInfo *read_buffer_info (Display *dpy, int nbufs) { @@ -405,7 +405,7 @@ Status XmbufGetWindowAttributes ( attr->buffers = (Multibuffer *) NULL; if ((attr->nbuffers = rep.length)) { int nbytes = rep.length * sizeof(Multibuffer); - attr->buffers = (Multibuffer *) Xmalloc((unsigned) nbytes); + attr->buffers = Xmalloc((unsigned) nbytes); nbytes = rep.length << 2; if (! attr->buffers) { _XEatDataWords(dpy, rep.length); diff --git a/src/XSecurity.c b/src/XSecurity.c index 56b37fc..2554502 100644 --- a/src/XSecurity.c +++ b/src/XSecurity.c @@ -283,7 +283,7 @@ XSecurityGenerateAuthorization( * XSecurityAllocXauth; in both cases, you just free one pointer. */ - if ((auth_return = (Xauth *)Xcalloc(1, + if ((auth_return = Xcalloc(1, (sizeof(Xauth) + auth_in->name_length + rep.dataLength)))) { auth_return->data_length = rep.dataLength; @@ -280,7 +280,7 @@ XImage *XShmCreateImage ( { register XImage *image; - image = (XImage *)Xcalloc(1, (unsigned)sizeof(XImage)); + image = Xcalloc(1, sizeof(XImage)); if (!image) return image; image->data = data; @@ -156,7 +156,7 @@ XcupGetReservedColormapEntries( } _XRead (dpy, (char*) rbufp, nbytes); - *colors_out = (XColor*) Xmalloc (nentries * sizeof (XColor)); + *colors_out = Xmalloc (nentries * sizeof (XColor)); if (*colors_out) { xColorItem* cs = (xColorItem *) rbufp; XColor* cd = *colors_out; @@ -443,8 +443,7 @@ XdbeBackBufferAttributes *XdbeGetBackBufferAttributes( DbeCheckExtension(dpy, info, (XdbeBackBufferAttributes *)NULL); - if (!(attr = - (XdbeBackBufferAttributes *)Xmalloc(sizeof(XdbeBackBufferAttributes)))) { + if (!(attr = Xmalloc(sizeof(XdbeBackBufferAttributes)))) { return NULL; } @@ -143,7 +143,7 @@ _xgeCheckExtInit(Display* dpy, XExtDisplayInfo* info) if (!info->data) { - XGEData* data = (XGEData*)Xmalloc(sizeof(XGEData)); + XGEData* data = Xmalloc(sizeof(XGEData)); if (!data) { goto cleanup; } @@ -192,7 +192,7 @@ _xgeGetExtensionVersion(Display* dpy, return NULL; } - vers = (XGEVersionRec*)Xmalloc(sizeof(XGEVersionRec)); + vers = Xmalloc(sizeof(XGEVersionRec)); vers->major_version = rep.majorVersion; vers->minor_version = rep.minorVersion; return vers; @@ -315,7 +315,7 @@ _X_HIDDEN xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks) xge_data = (XGEData*)info->data; - newExt = (XGEExtNode*)Xmalloc(sizeof(XGEExtNode)); + newExt = Xmalloc(sizeof(XGEExtNode)); if (!newExt) { fprintf(stderr, "xgeExtRegister: Failed to alloc memory.\n"); diff --git a/src/extutil.c b/src/extutil.c index e9d293f..26f90b2 100644 --- a/src/extutil.c +++ b/src/extutil.c @@ -63,8 +63,7 @@ in this Software without prior written authorization from The Open Group. */ XExtensionInfo *XextCreateExtension (void) { - register XExtensionInfo *info = - (XExtensionInfo *) Xmalloc (sizeof (XExtensionInfo)); + register XExtensionInfo *info = Xmalloc (sizeof (XExtensionInfo)); if (info) { info->head = NULL; @@ -101,7 +100,7 @@ XExtDisplayInfo *XextAddDisplay ( { XExtDisplayInfo *dpyinfo; - dpyinfo = (XExtDisplayInfo *) Xmalloc (sizeof (XExtDisplayInfo)); + dpyinfo = Xmalloc (sizeof (XExtDisplayInfo)); if (!dpyinfo) return NULL; dpyinfo->display = dpy; dpyinfo->data = data; |