diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-08-06 11:40:59 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-08-06 11:40:59 -0700 |
commit | 52b7307f42f99c81eda97a322dc3ffccd9e371f6 (patch) | |
tree | a23adc5bb17bc46936f296f325ccf1bfebdc4936 | |
parent | b0b9b4c5a134c559404b4052c2c42b9fcde66915 (diff) |
Remove unnnecessary casts from malloc(), calloc(), and free() calls
These are not needed in C89 and later.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | x2jet.c | 14 | ||||
-rw-r--r-- | x2pmp.c | 22 | ||||
-rw-r--r-- | xpr.c | 4 |
3 files changed, 19 insertions, 21 deletions
@@ -658,7 +658,7 @@ void prepare_color_mapping ( setup_RGBshiftmask(&color.sm, xwd_header.red_mask, xwd_header.green_mask, xwd_header.blue_mask); else { - if (!(colormap = (long *) malloc(xwd_header.ncolors * sizeof(long)))) + if (!(colormap = malloc(xwd_header.ncolors * sizeof(long)))) fatal_err((catgets(nlmsg_fd,NL_SETN,24, "Could not allocate memory for X-to-printer colormap."))); @@ -937,7 +937,7 @@ void add_index_to_chain ( * if possible, otherwise malloc space. */ if (color.freechain == NULL) { - if (!(new = (COLORINDEX *) malloc(sizeof(COLORINDEX)))) + if (!(new = malloc(sizeof(COLORINDEX)))) fatal_err((catgets(nlmsg_fd,NL_SETN,8, "Could not allocate memory for color translation."))); } else { @@ -1116,7 +1116,7 @@ void read_xwd_data (FILE *in) } /* Allocate space for xwd color structures */ - if (!(xwd_colors = (XColor*) malloc(sizeof(XColor) * xwd_header.ncolors))) + if (!(xwd_colors = malloc(sizeof(XColor) * xwd_header.ncolors))) fatal_err((catgets(nlmsg_fd,NL_SETN,12, "Could not allocate memory for xwdfile color table."))); @@ -1526,7 +1526,7 @@ void write_portrait_Z_image ( int height = limit.height; long *line, *lp; - if (!(line = (long *) malloc(width * sizeof(long)))) + if (!(line = malloc(width * sizeof(long)))) fatal_err((catgets(nlmsg_fd,NL_SETN,18, "Could not allocate memory for image line buffer."))); @@ -1551,7 +1551,7 @@ void write_landscape_Z_image ( int height = limit.width; long *line, *lp; - if (!(line = (long *) malloc(width * sizeof(long)))) + if (!(line = malloc(width * sizeof(long)))) fatal_err((catgets(nlmsg_fd,NL_SETN,19, "Could not allocate memory for image line buffer."))); @@ -1576,7 +1576,7 @@ void write_portrait_XY_image ( int height = limit.height; long *line, *lp; - if (!(line = (long *) malloc(width * sizeof(long)))) + if (!(line = malloc(width * sizeof(long)))) fatal_err((catgets(nlmsg_fd,NL_SETN,20, "Could not allocate memory for image line buffer."))); @@ -1601,7 +1601,7 @@ void write_landscape_XY_image ( int height = limit.width; long *line, *lp; - if (!(line = (long *) malloc(width * sizeof(long)))) + if (!(line = malloc(width * sizeof(long)))) fatal_err((catgets(nlmsg_fd,NL_SETN,21, "Could not allocate memory for image line buffer."))); @@ -65,8 +65,7 @@ void x2pmp(FILE *in, FILE *out, } win_name_size = abs_(header.header_size - sizeof(header)); - if ((win_name = (unsigned char *) - calloc(win_name_size, (unsigned) sizeof(char))) == NULL) + if ((win_name = calloc(win_name_size, sizeof(char))) == NULL) leave("Can't calloc window name storage."); /* Read window name from file */ @@ -113,7 +112,7 @@ void x2pmp(FILE *in, FILE *out, ncolors = header.ncolors; if (ncolors) { int i; - XColor *colors = (XColor *)malloc((unsigned) (header.ncolors * sizeof(XColor))); + XColor *colors = malloc((unsigned) (header.ncolors * sizeof(XColor))); if (fread((char *)colors, sizeof(XColor), ncolors, in) != ncolors) leave("Unable to read colormap from dump file."); @@ -131,7 +130,7 @@ void x2pmp(FILE *in, FILE *out, invert = !invert; /* 3812 puts ink (i.e. black) on 1-bits */ - if ((buffer = (unsigned char *) calloc(buffer_size, 1)) == NULL) + if ((buffer = calloc(buffer_size, 1)) == NULL) leave("Can't calloc data buffer."); bzero((char *) buffer, (int) buffer_size); @@ -182,8 +181,8 @@ void x2pmp(FILE *in, FILE *out, unsigned char *scale_buf; int i, j, k; - if ((scale_buf = (unsigned char *) - calloc((unsigned) (buffer_size *= scale*scale), sizeof(char))) + if ((scale_buf = + calloc((unsigned) (buffer_size *= scale*scale), sizeof(char))) == NULL) leave("Can't calloc scaled buffer."); for(i = 0; i < height; i++) { @@ -198,8 +197,8 @@ void x2pmp(FILE *in, FILE *out, } } } - free((char *) buffer); - free((char *) tbl); + free(buffer); + free(tbl); buffer = scale_buf; byte_width *= scale; width *= scale; @@ -236,8 +235,8 @@ void x2pmp(FILE *in, FILE *out, p_move_abs(out, x_pos, y_pos); p_bitmap(out, height, fixed_width, (unsigned long) one_plane_size, buffer + plane * one_plane_size); - free((char *) win_name); - free((char *) buffer); + free(win_name); + free(buffer); } static @@ -246,8 +245,7 @@ unsigned char *magnification_table(int scale) unsigned char *tbl; int c; - if ((tbl = (unsigned char *) - calloc((unsigned) (scale*256), sizeof(char))) == NULL) + if ((tbl = calloc((unsigned) (scale*256), sizeof(char))) == NULL) leave("Can't calloc magnification table."); bzero((char *) tbl, scale*256); for(c = 256; c--;) { @@ -329,7 +329,7 @@ int main(int argc, char **argv) if(win.ncolors) { XWDColor xwdcolor; - colors = (XColor *)malloc((unsigned) (win.ncolors * sizeof(XColor))); + colors = malloc((unsigned) (win.ncolors * sizeof(XColor))); for (i = 0; i < win.ncolors; i++) { fullread(0, (char*)&xwdcolor, (int) sizeof xwdcolor); colors[i].pixel = xwdcolor.pixel; @@ -1237,7 +1237,7 @@ void ps_output_bits( } bzero(obuf,owidth*oheight); - ibuf = (unsigned char *)malloc((unsigned)(iwb + 3)); + ibuf = malloc((unsigned)(iwb + 3)); for (i=0;i<ih;i++) { memcpy(ibuf, buffer, iwb); buffer += iwb; |