From dc8d02fd4ecce2757f0fa8f4ee5418035abd5a99 Mon Sep 17 00:00:00 2001 From: Martin Nilsson <nilsson@opera.com> Date: Sun, 27 Apr 2014 22:37:42 +0200 Subject: [PATCH] mallocs nowdays return void*, so no need to case. --- src/array.c | 18 +++++++++--------- src/backend.cmod | 5 ++--- src/block_allocator.c | 6 +++--- src/callback.c | 2 +- src/constants.c | 2 +- src/cpp.c | 12 ++++++------ src/docode.c | 4 ++-- src/dynamic_buffer.c | 4 ++-- src/dynamic_load.c | 2 +- src/encode.c | 6 +++--- src/fdlib.c | 12 ++++++------ src/hashtable.c | 8 ++++---- src/las.c | 4 ++-- src/modules/Gmp/next_prime.c | 2 +- src/modules/Image/colortable.c | 2 +- src/modules/Image/dct.c | 4 ++-- src/modules/Image/encodings/_xpm.c | 2 +- src/modules/Image/encodings/pcx.c | 8 ++++---- src/modules/Image/encodings/psd.c | 3 +-- src/modules/Image/encodings/ras.c | 6 +++--- src/modules/Image/encodings/tga.c | 4 ++-- src/modules/Image/encodings/x.c | 2 +- src/modules/Image/encodings/xcf.c | 18 +++++++++--------- src/modules/Image/font.c | 4 ++-- src/modules/Image/image.c | 12 ++++++------ src/modules/Image/pattern.c | 4 ++-- src/modules/Java/jvm.c | 19 +++++++++---------- src/modules/Regexp/pike_regexp.c | 4 ++-- src/modules/_Charset/charsetmod.c | 8 ++++---- src/modules/_Charset/iso2022.c | 8 ++++---- src/modules/_Image_GIF/gif_lzw.c | 2 +- src/modules/_Image_GIF/image_gif.c | 6 +++--- src/modules/_Image_JPEG/image_jpeg.c | 4 ++-- src/modules/_Image_TTF/image_ttf.c | 4 ++-- src/modules/_Stdio/efuns.c | 6 +++--- src/modules/_Stdio/file.c | 3 +-- src/modules/_Stdio/sendfile.c | 16 +++++----------- src/modules/_WhiteFish/blob.c | 2 +- src/modules/sybase/sybase.c | 14 +++++++------- src/modules/system/memory.c | 4 ++-- src/modules/system/nt.c | 8 ++++---- src/modules/system/system.c | 4 ++-- src/multiset.c | 6 +++--- src/peep.c | 2 +- src/post_modules/GTK1/source/support.c | 2 +- src/post_modules/GTK2/source/support.c | 2 +- src/post_modules/Nettle/hash.cmod | 12 +++++------- .../Shuffler/a_source_pikestring.c | 2 +- src/post_modules/_Image_WebP/image_webp.cmod | 4 ++-- src/signal_handler.c | 4 ++-- src/stack_allocator.c | 2 +- src/stralloc.c | 15 ++++++--------- 52 files changed, 152 insertions(+), 167 deletions(-) diff --git a/src/array.c b/src/array.c index 6ceea616bf..633031b02d 100644 --- a/src/array.c +++ b/src/array.c @@ -92,8 +92,8 @@ PMOD_EXPORT struct array *real_allocate_array(ptrdiff_t size, Pike_error("Too large array (size %ld exceeds %ld).\n", (long)(size+extra_space-1), (long)((LONG_MAX-sizeof(struct array))/sizeof(struct svalue)) ); - v=(struct array *)malloc(sizeof(struct array)+ - (size+extra_space-1)*sizeof(struct svalue)); + v=malloc(sizeof(struct array)+ + (size+extra_space-1)*sizeof(struct svalue)); if(!v) Pike_error(msg_out_of_mem_2, sizeof(struct array)+ (size+extra_space-1)*sizeof(struct svalue)); @@ -877,7 +877,7 @@ INT32 *get_order(struct array *v, cmpfun fun) if(!v->size) return 0; /* Overlow safe: ((1<<29)-4)*4 < ULONG_MAX */ - current_order=(INT32 *)xalloc(v->size * sizeof(INT32)); + current_order=xalloc(v->size * sizeof(INT32)); SET_ONERROR(tmp, free, current_order); for(e=0; e<v->size; e++) current_order[e]=e; @@ -1278,7 +1278,7 @@ PMOD_EXPORT INT32 *stable_sort_array_destructively(struct array *v) if(!v->size) return NULL; /* Overflow safe: ((1<<29)-4)*4 < ULONG_MAX */ - current_order=(INT32 *)xalloc(v->size * sizeof(INT32)); + current_order=xalloc(v->size * sizeof(INT32)); SET_ONERROR(tmp, free, current_order); for(e=0; e<v->size; e++) current_order[e]=e; @@ -1545,13 +1545,13 @@ INT32 * merge(struct array *a,struct array *b,INT32 opcode) { case PIKE_ARRAY_OP_AND: /* Trivially overflow safe */ - ret=(INT32 *)xalloc(sizeof(INT32)); + ret=xalloc(sizeof(INT32)); *ret=0; return ret; case PIKE_ARRAY_OP_SUB: /* Overlow safe: ((1<<29)-4+1)*4 < ULONG_MAX */ - ptr=ret=(INT32 *)xalloc(sizeof(INT32)*(a->size+1)); + ptr=ret=xalloc(sizeof(INT32)*(a->size+1)); *(ptr++)=a->size; for(i=0;i<a->size;i++) *(ptr++)=i; return ret; @@ -1561,7 +1561,7 @@ INT32 * merge(struct array *a,struct array *b,INT32 opcode) /* Note: The following is integer overflow safe as long as * sizeof(struct svalue) >= 2*sizeof(INT32). */ - ptr=ret=(INT32 *)xalloc(sizeof(INT32)*(a->size + b->size + 1)); + ptr=ret=xalloc(sizeof(INT32)*(a->size + b->size + 1)); SET_ONERROR(r, free,ret); ptr++; @@ -1923,7 +1923,7 @@ PMOD_EXPORT struct array *merge_array_without_order2(struct array *a, struct arr arra=ITEM(a); }else{ /* Overlow safe: ((1<<29)-4)*8 < ULONG_MAX */ - arra=(struct svalue *)xalloc(a->size*sizeof(struct svalue)); + arra=xalloc(a->size*sizeof(struct svalue)); MEMCPY(arra,ITEM(a),a->size*sizeof(struct svalue)); SET_ONERROR(r3,free,arra); } @@ -1933,7 +1933,7 @@ PMOD_EXPORT struct array *merge_array_without_order2(struct array *a, struct arr arrb=ITEM(b); }else{ /* Overlow safe: ((1<<29)-4)*8 < ULONG_MAX */ - arrb=(struct svalue *)xalloc(b->size*sizeof(struct svalue)); + arrb=xalloc(b->size*sizeof(struct svalue)); MEMCPY(arrb,ITEM(b),b->size*sizeof(struct svalue)); SET_ONERROR(r4,free,arrb); } diff --git a/src/backend.cmod b/src/backend.cmod index e525016c2b..38b909bce4 100644 --- a/src/backend.cmod +++ b/src/backend.cmod @@ -235,8 +235,7 @@ static void low_set_backend_for_fd(int fd, struct Backend_struct *b) if(!fd_map_size) fd_map_size=64; while(fd >= fd_map_size) fd_map_size*=2; if (fd_map) { - fd_map = (struct Backend_struct **) - realloc(fd_map, sizeof(struct Backend_struct *) * fd_map_size); + fd_map = realloc(fd_map, sizeof(struct Backend_struct *) * fd_map_size); } else { fd_map = calloc(sizeof(struct Backend_struct *), fd_map_size); } @@ -731,7 +730,7 @@ PIKECLASS Backend if (!me->call_hash) { me->hash_size = hashprimes[me->hash_order]; - me->call_hash = xcalloc(sizeof(struct hash_ent),me->hash_size); + me->call_hash = xcalloc(sizeof(struct hash_ent), me->hash_size); } }else{ struct hash_ent *new_hash; diff --git a/src/block_allocator.c b/src/block_allocator.c index 4090a2f506..1ed9160592 100644 --- a/src/block_allocator.c +++ b/src/block_allocator.c @@ -74,19 +74,19 @@ static struct ba_page * ba_alloc_page(struct block_allocator * a, int i) { size_t n = l.offset + l.block_size + l.doffset; struct ba_page * p; if (l.alignment) { - p = (struct ba_page*)aligned_alloc(n, l.alignment); + p = aligned_alloc(n, l.alignment); } else { #ifdef DEBUG_MALLOC /* In debug malloc mode, calling xalloc from the block alloc may result * in a deadlock, since xalloc will call ba_alloc, which in turn may call xalloc. */ - p = (struct ba_page*)system_malloc(n); + p = system_malloc(n); if (!p) { fprintf(stderr, "Fatal: Out of memory.\n"); exit(17); } #else - p = (struct ba_page*)xalloc(n); + p = xalloc(n); #endif } ba_clear_page(a, p, &a->l); diff --git a/src/callback.c b/src/callback.c index 080d0c9cf1..2d4e9fbc16 100644 --- a/src/callback.c +++ b/src/callback.c @@ -212,7 +212,7 @@ PMOD_EXPORT struct callback *debug_add_to_callback(struct callback_list *lst, callback_func free_func) { struct callback *l; - l=(struct callback*)ba_alloc(&callback_allocator); + l=ba_alloc(&callback_allocator); l->call=call; l->arg=arg; l->free_func=free_func; diff --git a/src/constants.c b/src/constants.c index e07c3db6ff..4a333fd103 100644 --- a/src/constants.c +++ b/src/constants.c @@ -99,7 +99,7 @@ PMOD_EXPORT struct callable *low_make_callable(c_fun fun, optimize_fun optimize, docode_fun docode) { - struct callable *f=(struct callable*)ba_alloc(&callable_allocator); + struct callable *f=ba_alloc(&callable_allocator); #ifdef PIKE_DEBUG DOUBLELINK(first_callable, f); #endif diff --git a/src/cpp.c b/src/cpp.c index 4adfaa0245..8400114859 100644 --- a/src/cpp.c +++ b/src/cpp.c @@ -1071,8 +1071,8 @@ static struct define *alloc_empty_define(struct pike_string *name, ptrdiff_t parts) { struct define *def; - def=(struct define *)xalloc(sizeof(struct define)+ - sizeof(struct define_part) * (parts -1)); + def=xalloc(sizeof(struct define)+ + sizeof(struct define_part) * (parts -1)); def->magic=0; def->args=-1; def->inside=0; @@ -2856,17 +2856,17 @@ void add_predefine(char *s) char * pos=STRCHR(s,'='); if(pos) { - tmp->name=(char *)xalloc(pos-s+1); + tmp->name=xalloc(pos-s+1); MEMCPY(tmp->name,s,pos-s); tmp->name[pos-s]=0; - tmp->value=(char *)xalloc(s+strlen(s)-pos); + tmp->value=xalloc(s+strlen(s)-pos); MEMCPY(tmp->value,pos+1,s+strlen(s)-pos); }else{ - tmp->name=(char *)xalloc(strlen(s)+1); + tmp->name=xalloc(strlen(s)+1); MEMCPY(tmp->name,s,strlen(s)+1); - tmp->value=(char *)xalloc(4); + tmp->value=xalloc(4); MEMCPY(tmp->value," 1 ",4); } tmp->next = NULL; diff --git a/src/docode.c b/src/docode.c index d5b938d38a..f527042b47 100644 --- a/src/docode.c +++ b/src/docode.c @@ -2086,8 +2086,8 @@ static int do_docode2(node *n, int flags) current_switch.less_label=-1; current_switch.greater_label=-1; current_switch.default_label=-1; - current_switch.jumptable=(INT32 *)xalloc(sizeof(INT32)*(cases*2+2)); - jumptable=(INT32 *)xalloc(sizeof(INT32)*(cases*2+2)); + current_switch.jumptable=xalloc(sizeof(INT32)*(cases*2+2)); + jumptable=xalloc(sizeof(INT32)*(cases*2+2)); for(e=1; e<cases*2+2; e++) { diff --git a/src/dynamic_buffer.c b/src/dynamic_buffer.c index ec99b15b58..116915042e 100644 --- a/src/dynamic_buffer.c +++ b/src/dynamic_buffer.c @@ -27,7 +27,7 @@ PMOD_EXPORT char *low_make_buf_space(ptrdiff_t space, dynamic_buffer *buf) buf->bufsize*=2; }while(buf->s.len+space >= buf->bufsize); - buf->s.str=(char *)realloc(buf->s.str, buf->bufsize); + buf->s.str=realloc(buf->s.str, buf->bufsize); if(!buf->s.str) Pike_fatal("Out of memory.\n"); } @@ -58,7 +58,7 @@ PMOD_EXPORT void low_my_binary_strcat(const char *b, size_t l, PMOD_EXPORT void debug_initialize_buf(dynamic_buffer *buf) { - buf->s.str=(char *)xalloc((buf->bufsize=BUFFER_BEGIN_SIZE)); + buf->s.str=xalloc((buf->bufsize=BUFFER_BEGIN_SIZE)); *(buf->s.str)=0; buf->s.len=0; } diff --git a/src/dynamic_load.c b/src/dynamic_load.c index 1c4007c897..dbef6e0444 100644 --- a/src/dynamic_load.c +++ b/src/dynamic_load.c @@ -128,7 +128,7 @@ static void dlclose(void *module) static TCHAR *convert_string(const char *str, ptrdiff_t len) { ptrdiff_t e; - TCHAR *ret=(TCHAR *)xalloc((len+1) * sizeof(TCHAR)); + TCHAR *ret=xalloc((len+1) * sizeof(TCHAR)); for(e=0;e<len;e++) ret[e]=EXTRACT_UCHAR(str+e); ret[e]=0; return ret; diff --git a/src/encode.c b/src/encode.c index f3e962c19d..31f100aeb9 100644 --- a/src/encode.c +++ b/src/encode.c @@ -1390,7 +1390,7 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc { int inherit_num = 1; struct svalue str_sval; - char *id_dumped = (char *) alloca(p->num_identifiers); + char *id_dumped = alloca(p->num_identifiers); int d_min = 0; MEMSET(id_dumped,0,p->num_identifiers); SET_SVAL(str_sval, T_STRING, 0, string, NULL); @@ -3727,8 +3727,8 @@ static void decode_value2(struct decode_data *data) "Placeholder already has storage!\n"); } else { placeholder->storage=p->storage_needed ? - (char *)xcalloc(p->storage_needed, 1) : - (char *)NULL; + xcalloc(p->storage_needed, 1) : + NULL; call_c_initializers(placeholder); } } diff --git a/src/fdlib.c b/src/fdlib.c index 6fc61247b2..8e27e5c725 100644 --- a/src/fdlib.c +++ b/src/fdlib.c @@ -1560,7 +1560,7 @@ PMOD_EXPORT DIR *opendir(char *dir) { ptrdiff_t len=strlen(dir); char *foo; - DIR *ret=(DIR *)malloc(sizeof(DIR) + len+5); + DIR *ret=malloc(sizeof(DIR) + len+5); if(!ret) { errno=ENOMEM; @@ -1623,7 +1623,7 @@ struct fd_mapper void init_fd_mapper(struct fd_mapper *x) { x->size=64; - x->data=(void **)xalloc(x->size*sizeof(void *)); + x->data=xalloc(x->size*sizeof(void *)); } void exit_fd_mapper(struct fd_mapper *x) @@ -1636,7 +1636,7 @@ void fd_mapper_set(struct fd_mapper *x, FD fd, void *data) while(fd>=x->size) { x->size*=2; - x->data=(void **)realloc((char *)x->data, x->size*sizeof(void *)); + x->data=realloc(x->data, x->size*sizeof(void *)); if(!x->data) Pike_fatal("Out of memory.\n"); x->data=nd; @@ -1667,7 +1667,7 @@ void init_fd_mapper(struct fd_mapper *x) int i; x->num=0; x->hsize=127; - x->data=(struct fd_mapper_data *)xalloc(x->hsize*sizeof(struct fd_mapper_data)); + x->data=xalloc(x->hsize*sizeof(struct fd_mapper_data)); for(i=0;i<x->hsize;i++) x->data[i].fd=-1; } @@ -1686,7 +1686,7 @@ void fd_mapper_set(struct fd_mapper *x, FD fd, void *data) int i,old_size=x->hsize; x->hsize*=3; x->num=0; - x->data=(struct fd_mapper_data *)xalloc(x->size*sizeof(struct fd_mapper_data *)); + x->data=xalloc(x->size*sizeof(struct fd_mapper_data *)); for(i=0;i<x->size;i++) x->data[i].fd=-1; for(i=0;i<old_size;i++) if(old[i].fd!=-1) @@ -1780,7 +1780,7 @@ void store_fd_data(FD fd, int key, void *data) else hash_size*=3; - htable=(struct fd_data_hash **)xalloc(hash_size * sizeof(struct fd_data_hash *)); + htable=xalloc(hash_size * sizeof(struct fd_data_hash *)); for(h=0;h<old_hsize;h++) { diff --git a/src/hashtable.c b/src/hashtable.c index 56b100f91e..e6eba7ac01 100644 --- a/src/hashtable.c +++ b/src/hashtable.c @@ -66,8 +66,8 @@ static void rehash_list_backwards(struct hash_table *h, struct hash_table *create_hash_table(void) { struct hash_table *new; - new=(struct hash_table *)calloc(1,sizeof(struct hash_table)+ - (NEW_HASHTABLE_SIZE-1)*sizeof(struct hash_entry *)); + new=calloc(1, sizeof(struct hash_table)+ + (NEW_HASHTABLE_SIZE-1)*sizeof(struct hash_entry *)); new->entries=0; new->mask=NEW_HASHTABLE_SIZE-1; return new; @@ -86,8 +86,8 @@ struct hash_table *hash_rehash(struct hash_table *h,int size) Pike_fatal("Size is not a power of two! Size: 0x%08x\n", size); #endif - new=(struct hash_table *)calloc(1,sizeof(struct hash_table)+ - (size-1)*sizeof(struct hash_entry *)); + new=calloc(1, sizeof(struct hash_table)+ + (size-1)*sizeof(struct hash_entry *)); new->mask = size - 1; new->entries = h->entries; diff --git a/src/las.c b/src/las.c index a51c8e1646..b72901dd6f 100644 --- a/src/las.c +++ b/src/las.c @@ -462,7 +462,7 @@ void really_free_node_s(node * n) { MALLOC_FUNCTION node * alloc_node_s() { - return (node*)ba_alloc(&Pike_compiler->node_allocator); + return ba_alloc(&Pike_compiler->node_allocator); } void count_memory_in_node_ss(size_t * num, size_t * size) { @@ -2495,7 +2495,7 @@ static struct used_vars *copy_vars(struct used_vars *a) struct used_vars *ret; struct scope_info *src; struct scope_info **dst; - ret=(struct used_vars *)xalloc(sizeof(struct used_vars)); + ret=xalloc(sizeof(struct used_vars)); src = a->locals; dst = &(ret->locals); *dst = NULL; diff --git a/src/modules/Gmp/next_prime.c b/src/modules/Gmp/next_prime.c index e113f243b5..cc69a963a6 100644 --- a/src/modules/Gmp/next_prime.c +++ b/src/modules/Gmp/next_prime.c @@ -172,7 +172,7 @@ mpz_next_prime(mpz_t p, mpz_t n, int count, int prime_limit) if (prime_limit) { /* Compute residues modulo small odd primes */ - moduli = (unsigned long*) alloca(prime_limit * sizeof(*moduli)); + moduli = alloca(prime_limit * sizeof(*moduli)); for (i = 0; i < prime_limit; i++) moduli[i] = mpz_fdiv_ui(p, primes[i + 1]); } diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c index 9237efef67..b09d5d3399 100644 --- a/src/modules/Image/colortable.c +++ b/src/modules/Image/colortable.c @@ -4067,7 +4067,7 @@ static int *ordered_make_diff(int *errors,int sz,int err) int n=sz; double q; - d=dest=(int*)malloc(sizeof(int)*sz); + d=dest=malloc(sizeof(int)*sz); if (!d) return d; if (sz!=1) q = DO_NOT_WARN(1.0/(sz-1)); else q=1.0; diff --git a/src/modules/Image/dct.c b/src/modules/Image/dct.c index 6cd5b84777..c0064b239a 100644 --- a/src/modules/Image/dct.c +++ b/src/modules/Image/dct.c @@ -114,8 +114,8 @@ void image_dct(INT32 args) "Bad arguments to image->dct()\n"); } - if (!(img->img=(rgb_group*)malloc(sizeof(rgb_group)* - img->xsize*img->ysize+RGB_VEC_PAD))) + if (!(img->img=malloc(sizeof(rgb_group)* + img->xsize*img->ysize+RGB_VEC_PAD))) { free(area); free(costbl); diff --git a/src/modules/Image/encodings/_xpm.c b/src/modules/Image/encodings/_xpm.c index 13b3cbc62d..61d43e1b04 100644 --- a/src/modules/Image/encodings/_xpm.c +++ b/src/modules/Image/encodings/_xpm.c @@ -332,7 +332,7 @@ void f__xpm_write_rows( INT32 args ) } if(ind > 127) { - p_colors[id] = (rgba_group *)realloc(p_colors[id],sizeof(rgba_group)*256); + p_colors[id] = realloc(p_colors[id],sizeof(rgba_group)*256); MEMSET(p_colors[id]+128, 0, sizeof(rgba_group)*128); } p_colors[id][ind]=parse_color_line( c, bpc ); diff --git a/src/modules/Image/encodings/pcx.c b/src/modules/Image/encodings/pcx.c index e1b8832e9d..27b438653d 100644 --- a/src/modules/Image/encodings/pcx.c +++ b/src/modules/Image/encodings/pcx.c @@ -129,7 +129,7 @@ void get_rle_decoded_from_data( unsigned char *dest, struct buffer * source, static void load_rgb_pcx( struct pcx_header *hdr, struct buffer *b, rgb_group *dest ) { - unsigned char *line = (unsigned char *)xalloc(hdr->bytesperline*hdr->planes); + unsigned char *line = xalloc(hdr->bytesperline*hdr->planes); struct rle_state state; int width, height; int x, y; @@ -157,7 +157,7 @@ static void load_rgb_pcx( struct pcx_header *hdr, struct buffer *b, static void load_mono_pcx( struct pcx_header *hdr, struct buffer *b, rgb_group *dest) { - unsigned char *line = (unsigned char *)xalloc(hdr->bytesperline*hdr->planes); + unsigned char *line = xalloc(hdr->bytesperline*hdr->planes); struct rle_state state; int width, height; int x, y; @@ -184,7 +184,7 @@ static void load_mono_pcx( struct pcx_header *hdr, struct buffer *b, static void load_planar_palette_pcx( struct pcx_header *hdr, struct buffer *b, rgb_group *dest) { - unsigned char *line = (unsigned char *)xalloc(hdr->bytesperline*hdr->planes); + unsigned char *line = xalloc(hdr->bytesperline*hdr->planes); struct rle_state state; rgb_group * palette = (rgb_group *)hdr->palette; int width, height; @@ -215,7 +215,7 @@ static void load_planar_palette_pcx( struct pcx_header *hdr, struct buffer *b, static void load_palette_pcx( struct pcx_header *hdr, struct buffer *b, rgb_group *dest) { - unsigned char *line = (unsigned char *)xalloc(hdr->bytesperline*hdr->planes); + unsigned char *line = xalloc(hdr->bytesperline*hdr->planes); struct rle_state state; /* It's at the end of the 'file' */ rgb_group * palette = (rgb_group *)(b->str+b->len-(256*3)); diff --git a/src/modules/Image/encodings/psd.c b/src/modules/Image/encodings/psd.c index 2655081266..cfe46ecec1 100644 --- a/src/modules/Image/encodings/psd.c +++ b/src/modules/Image/encodings/psd.c @@ -206,8 +206,7 @@ static void decode_layers_and_masks( struct psd_image *dst, while( count-- ) { unsigned int cnt; - struct layer *l= - layer = (struct layer *)xcalloc( sizeof( struct layer ), 1); + struct layer *l = layer = xcalloc( sizeof( struct layer ), 1); layer->next = dst->first_layer; if(dst->first_layer) dst->first_layer->prev = layer; dst->first_layer = layer; diff --git a/src/modules/Image/encodings/ras.c b/src/modules/Image/encodings/ras.c index a7ed3d4e1b..8407af0338 100644 --- a/src/modules/Image/encodings/ras.c +++ b/src/modules/Image/encodings/ras.c @@ -236,7 +236,7 @@ void img_ras_decode(INT32 args) img_sz = ((rs.ras_width+1)&~1)*3*rs.ras_height; break; } - tmpdata = (unsigned char *)xalloc(img_sz); + tmpdata = xalloc(img_sz); len = unpack_rle(src, len, tmpdata, img_sz); src = tmpdata; } @@ -479,7 +479,7 @@ static void img_ras_encode(INT32 args) STR0(cts)[rs.ras_maplength] = '\0'; rs.ras_maplength++; } - tmp = (unsigned char *)xalloc(rs.ras_maplength); + tmp = xalloc(rs.ras_maplength); image_colortable_write_rgb(ct, tmp); for(i=0; i<n; i++) { STR0(cts)[i] = tmp[i*3]; @@ -556,7 +556,7 @@ static void img_ras_encode(INT32 args) image_colortable_free_dither(&dith); { - unsigned char *pkdata = (unsigned char *)xalloc(rs.ras_length+16); + unsigned char *pkdata = xalloc(rs.ras_length+16); unsigned char *pk = pkdata, *src = STR0(res2); ptrdiff_t pklen = 0, pkleft = rs.ras_length+16; for(y=0; y<img->ysize; y++) { diff --git a/src/modules/Image/encodings/tga.c b/src/modules/Image/encodings/tga.c index c7104c9309..b8eb855a3b 100644 --- a/src/modules/Image/encodings/tga.c +++ b/src/modules/Image/encodings/tga.c @@ -287,7 +287,7 @@ static ptrdiff_t rle_fread (guchar *buf, size_t datasize, size_t nelems, { /* Allocate the state buffer if we haven't already. */ if (!statebuf) - statebuf = (unsigned char *) malloc (RLE_PACKETSIZE * datasize); + statebuf = malloc (RLE_PACKETSIZE * datasize); p = statebuf; } @@ -556,7 +556,7 @@ static struct image_alpha ReadImage(struct buffer *fp, struct tga_header *hdr) /* Allocate the data. */ - data = (guchar *) malloc (ROUNDUP_DIVIDE((width * height * bpp), 8)); + data = malloc (ROUNDUP_DIVIDE((width * height * bpp), 8)); if(!data) Pike_error("TGA: malloc failed\n"); diff --git a/src/modules/Image/encodings/x.c b/src/modules/Image/encodings/x.c index c29774bab1..17b006f041 100644 --- a/src/modules/Image/encodings/x.c +++ b/src/modules/Image/encodings/x.c @@ -202,7 +202,7 @@ static void image_x_encode_truecolor(INT32 args) if (nct) { - tmp=(rgb_group*)xalloc(sizeof(rgb_group)*img->xsize*img->ysize +RGB_VEC_PAD); + tmp=xalloc(sizeof(rgb_group)*img->xsize*img->ysize +RGB_VEC_PAD); if (!image_colortable_map_image(nct,img->img,tmp, img->xsize*img->ysize,img->xsize)) { diff --git a/src/modules/Image/encodings/xcf.c b/src/modules/Image/encodings/xcf.c index 46902e42bb..22d31572c1 100644 --- a/src/modules/Image/encodings/xcf.c +++ b/src/modules/Image/encodings/xcf.c @@ -516,7 +516,7 @@ static struct level read_level( struct buffer *buff, { struct buffer ob = *initial; int offset2 = read_uint( buff ); - struct tile *tile = (struct tile *)xalloc(sizeof(struct tile)); + struct tile *tile = xalloc(sizeof(struct tile)); read_data( &ob, offset ); if(last_tile) last_tile->next = tile; @@ -568,7 +568,7 @@ static struct layer_mask read_layer_mask( struct buffer *buff, tmp = read_property( buff ); if(tmp.type) { - struct property *s = (struct property *)xalloc(sizeof(struct property)); + struct property *s = xalloc(sizeof(struct property)); *s = tmp; s->next = res.first_property; res.first_property = s; @@ -605,7 +605,7 @@ static struct channel read_channel( struct buffer *buff, tmp = read_property( buff ); if(tmp.type) { - struct property *s =(struct property *)xalloc( sizeof(struct property )); + struct property *s = xalloc( sizeof(struct property )); *s = tmp; s->next = res.first_property; res.first_property = s; @@ -644,7 +644,7 @@ static struct layer read_layer( struct buffer *buff, struct buffer *initial ) tmp = read_property( buff ); if(tmp.type) { - struct property *s=(struct property *)xalloc( sizeof(struct property )); + struct property *s=xalloc( sizeof(struct property )); *s = tmp; s->next = res.first_property; res.first_property = s; @@ -657,7 +657,7 @@ static struct layer read_layer( struct buffer *buff, struct buffer *initial ) if(lm_offset) { struct buffer loffset = *initial; - struct layer_mask *m=(struct layer_mask *)xalloc(sizeof(struct layer_mask)); + struct layer_mask *m=xalloc(sizeof(struct layer_mask)); res.mask = m; read_data( &loffset, lm_offset ); MEMSET(m, 0, sizeof( struct layer_mask )); @@ -712,7 +712,7 @@ static struct gimp_image read_image( struct buffer * data ) tmp = read_property( data ); if(tmp.type) { - struct property *s= (struct property *)xalloc( sizeof(struct property )); + struct property *s=xalloc( sizeof(struct property )); *s = tmp; s->next = res.first_property; res.first_property = s; @@ -727,7 +727,7 @@ static struct gimp_image read_image( struct buffer * data ) tmp = read_layer( &layer_data, &initial ); if( tmp.width && tmp.height ) { - struct layer *s = (struct layer *)xalloc( sizeof(struct layer)); + struct layer *s = xalloc( sizeof(struct layer)); *s = tmp; s->next = res.first_layer; res.first_layer = s; @@ -742,7 +742,7 @@ static struct gimp_image read_image( struct buffer * data ) tmp = read_channel( &channel_data, &initial ); if( tmp.width && tmp.height ) { - struct channel *s = (struct channel *)xalloc( sizeof(struct channel)); + struct channel *s = xalloc( sizeof(struct channel)); *s = tmp; s->next = res.first_channel; res.first_channel = s; @@ -1239,7 +1239,7 @@ void image_xcf_f__decode_tiles( INT32 args ) int i; od.s = NULL; od.len = eheight*ewidth*bpp; /* Max and only size, really */ - df = (char *)(od.str = (unsigned char *)xalloc( eheight*ewidth*bpp+1 )); + df = (char *)(od.str = xalloc( eheight*ewidth*bpp+1 )); d = od; for(i=0; i<bpp; i++) diff --git a/src/modules/Image/font.c b/src/modules/Image/font.c index c208d3d44c..d3e740ab9e 100644 --- a/src/modules/Image/font.c +++ b/src/modules/Image/font.c @@ -343,7 +343,7 @@ void font_load(INT32 args) else { #endif - fh = (struct file_head *)xalloc(size); + fh = xalloc(size); #ifdef FONT_DEBUG fprintf(stderr,"FONT Malloced %p (%d)\n", fh, size); #endif @@ -532,7 +532,7 @@ void font_write(INT32 args) maxwidth2=1; - width_of=(int *)xalloc((args+1)*sizeof(int)); + width_of=xalloc((args+1)*sizeof(int)); SET_ONERROR(err, free, width_of); for (j=0; j<args; j++) diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c index 350aa4d790..a44f70f7e6 100644 --- a/src/modules/Image/image.c +++ b/src/modules/Image/image.c @@ -633,7 +633,7 @@ void img_read_grey(INT32 args) int n=THIS->xsize*THIS->ysize; rgb_group *d; img_read_get_channel(1,"grey",args,&m1,&s1,&c1); - d=THIS->img=(rgb_group*)xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); + d=THIS->img=xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); switch (m1) { case 0: MEMSET(d,c1,n*sizeof(rgb_group)); break; @@ -651,7 +651,7 @@ void img_read_rgb(INT32 args) img_read_get_channel(1,"red",args,&m1,&s1,&(rgb.r)); img_read_get_channel(2,"green",args,&m2,&s2,&(rgb.g)); img_read_get_channel(3,"blue",args,&m3,&s3,&(rgb.b)); - d=THIS->img=(rgb_group*)xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); + d=THIS->img=xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); switch (m1|(m2<<4)|(m3<<4)) { @@ -705,7 +705,7 @@ void img_read_cmyk(INT32 args) img_read_get_channel(2,"magenta",args,&m2,&s2,&(rgb.g)); img_read_get_channel(3,"yellow",args,&m3,&s3,&(rgb.b)); img_read_get_channel(4,"black",args,&m4,&s4,&k); - d=THIS->img=(rgb_group*)xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); + d=THIS->img=xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); while (n--) { @@ -744,7 +744,7 @@ void img_read_adjusted_cmyk(INT32 args) img_read_get_channel(2,"magenta",args,&m2,&s2,&(rgb.g)); img_read_get_channel(3,"yellow",args,&m3,&s3,&(rgb.b)); img_read_get_channel(4,"black",args,&m4,&s4,&k); - d=THIS->img=(rgb_group*)xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); + d=THIS->img=xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); while (n--) { @@ -801,7 +801,7 @@ void img_read_cmy(INT32 args) img_read_get_channel(1,"cyan",args,&m1,&s1,&(rgb.r)); img_read_get_channel(2,"magenta",args,&m2,&s2,&(rgb.g)); img_read_get_channel(3,"yellow",args,&m3,&s3,&(rgb.b)); - d=THIS->img=(rgb_group*)xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); + d=THIS->img=xalloc(sizeof(rgb_group)*n+RGB_VEC_PAD); while (n--) { @@ -913,7 +913,7 @@ void image_create_method(INT32 args) { if (args<2) push_int(0); - THIS->img=(rgb_group*) + THIS->img= xalloc(sizeof(rgb_group)*THIS->xsize*THIS->ysize+RGB_VEC_PAD); if (args>2) pop_n_elems(args-2); diff --git a/src/modules/Image/pattern.c b/src/modules/Image/pattern.c index 25bbf5780c..6a4a0e2303 100644 --- a/src/modules/Image/pattern.c +++ b/src/modules/Image/pattern.c @@ -251,8 +251,8 @@ static void init_colorrange(rgb_group *cr,struct svalue *s,char *where) else if (s->u.array->size<2) Pike_error("Colorrange array too small (meaningless) (to %s)\n",where); - vp=v=(void*)xalloc(sizeof(double)*(s->u.array->size/2+1)); - rgbp=rgb=(void*)xalloc(sizeof(rgbd_group)*(s->u.array->size/2+1)); + vp=v=xalloc(sizeof(double)*(s->u.array->size/2+1)); + rgbp=rgb=xalloc(sizeof(rgbd_group)*(s->u.array->size/2+1)); for (i=0; i<s->u.array->size-1; i+=2) { diff --git a/src/modules/Java/jvm.c b/src/modules/Java/jvm.c index 8c7e1d9f46..468c58814b 100644 --- a/src/modules/Java/jvm.c +++ b/src/modules/Java/jvm.c @@ -715,7 +715,7 @@ static void make_jargs(jvalue *jargs, INT32 args, char *dorelease, char *sig, case 0: { /* Extra byte added to avoid zero length allocation */ - jchar *newstr = (jchar *) xalloc(2 * sv->u.string->len + 1); + jchar *newstr = xalloc(2 * sv->u.string->len + 1); INT32 i; p_wchar0 *p = STR0(sv->u.string); for(i=sv->u.string->len; --i>=0; ) @@ -734,7 +734,7 @@ static void make_jargs(jvalue *jargs, INT32 args, char *dorelease, char *sig, { /* FIXME?: Does not make surrogates for plane 1-16 in group 0... */ /* Extra byte added to avoid zero length allocation */ - jchar *newstr = (jchar *) xalloc(2 * sv->u.string->len + 1); + jchar *newstr = xalloc(2 * sv->u.string->len + 1); INT32 i; p_wchar2 *p = STR2(sv->u.string); for(i=sv->u.string->len; --i>=0; ) @@ -823,8 +823,8 @@ static void f_call_static(INT32 args) return; } - jargs = (m->nargs>0?(jvalue *)xalloc(m->nargs*sizeof(jvalue)):NULL); - dorelease = (m->nargs>0?(char *)xalloc(m->nargs*sizeof(char)):NULL); + jargs = (m->nargs>0?xalloc(m->nargs*sizeof(jvalue)):NULL); + dorelease = (m->nargs>0?xalloc(m->nargs*sizeof(char)):NULL); make_jargs(jargs, args, dorelease, m->sig->str, co->jvm, env); switch(m->rettype) { @@ -935,8 +935,8 @@ static void f_call_virtual(INT32 args) return; } - jargs = (m->nargs>0?(jvalue *)xalloc(m->nargs*sizeof(jvalue)):NULL); - dorelease = (m->nargs>0?(char *)xalloc(m->nargs*sizeof(char)):NULL); + jargs = (m->nargs>0?xalloc(m->nargs*sizeof(jvalue)):NULL); + dorelease = (m->nargs>0?xalloc(m->nargs*sizeof(char)):NULL); make_jargs(jargs, args-1, dorelease, m->sig->str, co->jvm, env); switch(m->rettype) { @@ -1047,8 +1047,8 @@ static void f_call_nonvirtual(INT32 args) return; } - jargs = (m->nargs>0?(jvalue *)xalloc(m->nargs*sizeof(jvalue)):NULL); - dorelease = (m->nargs>0?(char *)xalloc(m->nargs*sizeof(char)):NULL); + jargs = (m->nargs>0?xalloc(m->nargs*sizeof(jvalue)):NULL); + dorelease = (m->nargs>0?xalloc(m->nargs*sizeof(char)):NULL); make_jargs(jargs, args-1, dorelease, m->sig->str, co->jvm, env); switch(m->rettype) { @@ -2604,8 +2604,7 @@ static void f_natives_create(INT32 args) free(n->jnms); n->jnms = NULL; } - n->jnms = (JNINativeMethod *) - xalloc(arr->size * sizeof(JNINativeMethod)); + n->jnms = xalloc(arr->size * sizeof(JNINativeMethod)); if (n->cons) { mexec_free(n->cons); diff --git a/src/modules/Regexp/pike_regexp.c b/src/modules/Regexp/pike_regexp.c index 389a61b7f2..abf85061a1 100644 --- a/src/modules/Regexp/pike_regexp.c +++ b/src/modules/Regexp/pike_regexp.c @@ -261,7 +261,7 @@ regexp *pike_regcomp(char *exp,int excompat) if (exp == (char *)NULL) FAIL("NULL argument"); - exp2=(short*)xalloc( (strlen(exp)+1) * sizeof(short) ); + exp2=xalloc( (strlen(exp)+1) * sizeof(short) ); for ( scan=exp,dest=exp2;( c= UCHARAT(scan++)); ) { switch (c) { case '(': @@ -316,7 +316,7 @@ regexp *pike_regcomp(char *exp,int excompat) FAIL("regexp too big"); /* Allocate space. */ - r = (regexp *) xalloc(sizeof(regexp) + (unsigned) regsize); + r = xalloc(sizeof(regexp) + (unsigned) regsize); /* Second pass: emit code. */ regparse = exp2; diff --git a/src/modules/_Charset/charsetmod.c b/src/modules/_Charset/charsetmod.c index 6361bb2bac..d64cbff4ef 100644 --- a/src/modules/_Charset/charsetmod.c +++ b/src/modules/_Charset/charsetmod.c @@ -1275,7 +1275,7 @@ static void f_create_sjise(INT32 args) s->lo = 0x5c; s->hi = 0xfffd; - s->revtab = (p_wchar1 *)xcalloc(s->hi-s->lo, sizeof(p_wchar1)); + s->revtab = xcalloc(s->hi-s->lo, sizeof(p_wchar1)); for(z=0, i=33; i<=126; i++, z+=94) for(j=33; j<=126; j++) { @@ -1343,7 +1343,7 @@ static void f_create_euce(INT32 args) s->lo = 128; s->hi = 128; - s->revtab = (p_wchar1 *)xcalloc(65536-s->lo, sizeof(p_wchar1)); + s->revtab = xcalloc(65536-s->lo, sizeof(p_wchar1)); for(z=0, i=33; i<=126; i++, z+=94) for(j=33; j<=126; j++) { @@ -1400,7 +1400,7 @@ static struct std8e_stor *push_std_8bite(int args, int allargs, int lo, int hi) pop_n_elems(allargs); push_object(o); s8 = (struct std8e_stor *)(sp[-1].u.object->storage+std8e_stor_offs); - s8->revtab = (p_wchar0 *)xcalloc(hi-lo, sizeof(p_wchar0)); + s8->revtab = xcalloc(hi-lo, sizeof(p_wchar0)); s8->lo = lo; s8->hi = hi; s8->lowtrans = 0; @@ -1418,7 +1418,7 @@ static struct std16e_stor *push_std_16bite(int args, int allargs, int lo, int hi pop_n_elems(allargs); push_object(o); s16 = (struct std16e_stor *)(sp[-1].u.object->storage+std16e_stor_offs); - s16->revtab = (p_wchar1 *)xcalloc(hi-lo, sizeof(p_wchar1)); + s16->revtab = xcalloc(hi-lo, sizeof(p_wchar1)); s16->lo = lo; s16->hi = hi; s16->lowtrans = 0; diff --git a/src/modules/_Charset/iso2022.c b/src/modules/_Charset/iso2022.c index 9813f4936b..6749a19a02 100644 --- a/src/modules/_Charset/iso2022.c +++ b/src/modules/_Charset/iso2022.c @@ -1153,7 +1153,7 @@ static void eat_enc_string(struct pike_string *str, struct iso2022enc_stor *s, if(index!=0 && (ttab = transltab[mode][index-0x10])!=NULL) { switch(mode) { case MODE_94: - rmap = (p_wchar1 *)xcalloc(0x10000-0x100, sizeof(p_wchar1)); + rmap = xcalloc(0x10000-0x100, sizeof(p_wchar1)); for(ch=0; ch<94; ch++) if(ttab[ch]>=0x100 && ttab[ch]!=0xfffd) rmap[ttab[ch]-0x100]=ch+33; @@ -1173,7 +1173,7 @@ static void eat_enc_string(struct pike_string *str, struct iso2022enc_stor *s, ttab = NULL; break; case MODE_96: - rmap = (p_wchar1 *)xcalloc(0x10000-0x100, sizeof(p_wchar1)); + rmap = xcalloc(0x10000-0x100, sizeof(p_wchar1)); for(ch=0; ch<96; ch++) if(ttab[ch]>=0x100 && ttab[ch]!=0xfffd) rmap[ttab[ch]-0x100]=ch+32; @@ -1193,7 +1193,7 @@ static void eat_enc_string(struct pike_string *str, struct iso2022enc_stor *s, ttab = NULL; break; case MODE_9494: - rmap = (p_wchar1 *)xcalloc(0x10000-0x100, sizeof(p_wchar1)); + rmap = xcalloc(0x10000-0x100, sizeof(p_wchar1)); for(ttt=ttab, ch=0; ch<94; ch++) for(ch2=0; ch2<94; ch2++, ttt++) if(*ttt>=0x100 && *ttt!=0xfffd) @@ -1220,7 +1220,7 @@ static void eat_enc_string(struct pike_string *str, struct iso2022enc_stor *s, ttab = NULL; break; case MODE_9696: - rmap = (p_wchar1 *)xcalloc(0x10000-0x100, sizeof(p_wchar1)); + rmap = xcalloc(0x10000-0x100, sizeof(p_wchar1)); for(ttt=ttab, ch=0; ch<96; ch++) for(ch2=0; ch2<96; ch2++, ttt++) if(*ttt>=0x100 && *ttt!=0xfffd) diff --git a/src/modules/_Image_GIF/gif_lzw.c b/src/modules/_Image_GIF/gif_lzw.c index 6679d21a63..fc19f22ce9 100644 --- a/src/modules/_Image_GIF/gif_lzw.c +++ b/src/modules/_Image_GIF/gif_lzw.c @@ -172,7 +172,7 @@ void image_gif_lzw_init(struct gif_lzw *lzw,int bits) lzw->codes=(1L<<bits)+2; lzw->bits=bits; lzw->codebits=bits+1; - lzw->code=(struct gif_lzwc*) malloc(sizeof(struct gif_lzwc)*4096); + lzw->code=malloc(sizeof(struct gif_lzwc)*4096); if (!lzw->code) { lzw->broken=1; return; } diff --git a/src/modules/_Image_GIF/image_gif.c b/src/modules/_Image_GIF/image_gif.c index c6e396cbdf..737c88db65 100644 --- a/src/modules/_Image_GIF/image_gif.c +++ b/src/modules/_Image_GIF/image_gif.c @@ -1682,7 +1682,7 @@ fprintf(stderr,"_gif_decode_lzw(%lx,%lu,%d,%lx,%lx,%lx,%lu,%d)\n", #define MAX_GIF_CODE 4096 - c=(struct lzwc*)xalloc(sizeof(struct lzwc)*MAX_GIF_CODE); + c=xalloc(sizeof(struct lzwc)*MAX_GIF_CODE); for (n=0; n<clearcode; n++) c[n].prev=0xffff,c[n].len=1,c[n].c=n; @@ -2569,9 +2569,9 @@ static void image_gif_lzw_decode(INT32 args) last=clearcode; - c=(struct lzwc*)xalloc(sizeof(struct lzwc)*MAX_GIF_CODE); + c=xalloc(sizeof(struct lzwc)*MAX_GIF_CODE); - dest0=(unsigned char*)malloc(dlen0=len*4); + dest0=malloc(dlen0=len*4); if (!dest0) { free(c); diff --git a/src/modules/_Image_JPEG/image_jpeg.c b/src/modules/_Image_JPEG/image_jpeg.c index 3add6bdbc3..00ce77556a 100644 --- a/src/modules/_Image_JPEG/image_jpeg.c +++ b/src/modules/_Image_JPEG/image_jpeg.c @@ -198,7 +198,7 @@ static boolean my_jpeg_marker_parser(j_decompress_ptr cinfo) length-=2; length &= 0xffff; - mm=(struct my_marker*)xalloc(sizeof(struct my_marker)+length); + mm=xalloc(sizeof(struct my_marker)+length); mm->id=cinfo->unread_marker; mm->len=length; mm->next=mds->first_marker; @@ -242,7 +242,7 @@ static boolean my_empty_output_buffer(struct jpeg_compress_struct *cinfo) char *new; pos=dm->len; /* foo! dm->len-dm->pub.free_in_buffer; */ - new=(char*)realloc(dm->buf,dm->len+BUF_INCREMENT); + new=realloc(dm->buf,dm->len+BUF_INCREMENT); if (!new) return FALSE; dm->buf = new; diff --git a/src/modules/_Image_TTF/image_ttf.c b/src/modules/_Image_TTF/image_ttf.c index c6c2e55b48..6c3aa38361 100644 --- a/src/modules/_Image_TTF/image_ttf.c +++ b/src/modules/_Image_TTF/image_ttf.c @@ -730,7 +730,7 @@ static void ttf_translate_8bit(TT_CharMap charMap, { int i; - dest[0]=(int*)xalloc(len*sizeof(int)); + dest[0]=xalloc(len*sizeof(int)); THREADS_ALLOW(); for (i=0; i<len; i++) @@ -747,7 +747,7 @@ static void ttf_translate_16bit(TT_CharMap charMap, { int i; - dest[0]=(int*)xalloc(len*sizeof(int)); + dest[0]=xalloc(len*sizeof(int)); THREADS_ALLOW(); for (i=0; i<len; i++) diff --git a/src/modules/_Stdio/efuns.c b/src/modules/_Stdio/efuns.c index 348b7ac49b..7a08aa82ab 100644 --- a/src/modules/_Stdio/efuns.c +++ b/src/modules/_Stdio/efuns.c @@ -1458,7 +1458,7 @@ void f_getcwd(INT32 args) size=1000; do { - tmp=(char *)xalloc(size); + tmp=xalloc(size); e = getcwd(tmp,size); if (e || errno!=ERANGE) break; free(tmp); @@ -1559,7 +1559,7 @@ void f_exece(INT32 args) SIMPLE_BAD_ARG_ERROR("exece", 1, "string"); } - argv=(char **)xalloc((2+sp[1-args].u.array->size) * sizeof(char *)); + argv=xalloc((2+sp[1-args].u.array->size) * sizeof(char *)); argv[0]=sp[0-args].u.string->str; @@ -1576,7 +1576,7 @@ void f_exece(INT32 args) INT32 e, i = 0; struct keypair *k; - env=(char **)malloc((1+m_sizeof(en)) * sizeof(char *)); + env=malloc((1+m_sizeof(en)) * sizeof(char *)); if(!env) { free(argv); SIMPLE_OUT_OF_MEMORY_ERROR("exece", (1+m_sizeof(en)*sizeof(char *))); diff --git a/src/modules/_Stdio/file.c b/src/modules/_Stdio/file.c index 09a7af9927..3eae235f6c 100644 --- a/src/modules/_Stdio/file.c +++ b/src/modules/_Stdio/file.c @@ -1889,8 +1889,7 @@ static void file_write(INT32 args) push_int(0); return; } else { - struct iovec *iovbase = - (struct iovec *)xalloc(sizeof(struct iovec)*a->size); + struct iovec *iovbase = xalloc(sizeof(struct iovec)*a->size); struct iovec *iov = iovbase; int iovcnt = a->size; diff --git a/src/modules/_Stdio/sendfile.c b/src/modules/_Stdio/sendfile.c index ef3a3d80ca..60e040fbdd 100644 --- a/src/modules/_Stdio/sendfile.c +++ b/src/modules/_Stdio/sendfile.c @@ -1017,7 +1017,7 @@ static void sf_create(INT32 args) iovcnt = 2; #endif /* HAVE_HPUX_SENDFILE */ - sf.iovs = (struct iovec *)xalloc(sizeof(struct iovec) * iovcnt); + sf.iovs = xalloc(sizeof(struct iovec) * iovcnt); sf.hd_iov = sf.iovs; #ifdef HAVE_HPUX_SENDFILE @@ -1120,16 +1120,10 @@ static void sf_create(INT32 args) if (sf.from_file) { /* We may need a buffer to hold the data */ - if (sf.iovs) { - ONERROR tmp; - SET_ONERROR(tmp, free, sf.iovs); - - sf.buffer = (char *)xalloc(BUF_SIZE); - - UNSET_ONERROR(tmp); - } else { - sf.buffer = (char *)xalloc(BUF_SIZE); - } + ONERROR tmp; + SET_ONERROR(tmp, free, sf.iovs); + sf.buffer = xalloc(BUF_SIZE); + UNSET_ONERROR(tmp); sf.buf_size = BUF_SIZE; } diff --git a/src/modules/_WhiteFish/blob.c b/src/modules/_WhiteFish/blob.c index bd246c0c48..f2852a71a0 100644 --- a/src/modules/_WhiteFish/blob.c +++ b/src/modules/_WhiteFish/blob.c @@ -529,7 +529,7 @@ static void f_blob__cast( INT32 args ) #ifdef HANDLES_UNALIGNED_READ fsort( zipp[i].b->data+5, nh, 2, (void *)cmp_hit ); #else - short *data = (short *)malloc( nh * 2 ); + short *data = malloc( nh * 2 ); MEMCPY( data, zipp[i].b->data+5, nh * 2 ); fsort( data, nh, 2, (void *)cmp_hit ); MEMCPY( zipp[i].b->data+5, data, nh * 2 ); diff --git a/src/modules/sybase/sybase.c b/src/modules/sybase/sybase.c index b1cfcd323e..e10cb4af2f 100644 --- a/src/modules/sybase/sybase.c +++ b/src/modules/sybase/sybase.c @@ -741,9 +741,9 @@ static void f_big_query(INT32 args) { sybdebug((stderr,"I have %d columns' worth of data\n",numcols)); sybdebug((stderr,"Allocating results**\n")); /* it looks like xalloc can't be used here. Hubbe? */ - results=(char**)malloc(numcols*sizeof(char*)); - results_lengths=(CS_INT*)malloc(numcols*sizeof(CS_INT)); - nulls=(CS_SMALLINT*)malloc(numcols*sizeof(CS_SMALLINT)); + results=malloc(numcols*sizeof(char*)); + results_lengths=malloc(numcols*sizeof(CS_INT)); + nulls=malloc(numcols*sizeof(CS_SMALLINT)); this->results=results; this->results_lengths=results_lengths; this->nulls=nulls; @@ -765,8 +765,8 @@ static void f_big_query(INT32 args) { sybdebug((stderr,"Allocating %ld+%d+1 bytes\n", length,EXTRA_COLUMN_SPACE)); /* it looks like xalloc can't be used here. Hubbe? */ - results[j]=(char*)malloc((length+EXTRA_COLUMN_SPACE+1)* - sizeof(char)); + results[j]=malloc((length+EXTRA_COLUMN_SPACE+1)* + sizeof(char)); if (results[j]==NULL) { sybdebug((stderr,"PANIC! COULDN'T ALLOCATE MEMORY!")); } @@ -799,8 +799,8 @@ static void f_big_query(INT32 args) { length=guess_column_length(cmd,1); sybdebug((stderr,"Guessed length of %d\n",length)); - function_result=(char*)malloc((length+EXTRA_COLUMN_SPACE+1)* - sizeof(char)); + function_result=malloc((length+EXTRA_COLUMN_SPACE+1)* + sizeof(char)); description.datatype=CS_CHAR_TYPE; description.format=CS_FMT_NULLTERM; diff --git a/src/modules/system/memory.c b/src/modules/system/memory.c index cdf5efaec2..5416ac4a59 100644 --- a/src/modules/system/memory.c +++ b/src/modules/system/memory.c @@ -464,13 +464,13 @@ static void memory_allocate(INT32 args) if (size>1024*1024) /* threshold */ { THREADS_ALLOW(); - mem = (unsigned char *)xalloc(size); + mem = xalloc(size); MEMSET(mem,c,size); THREADS_DISALLOW(); } else { - mem = (unsigned char *)xalloc(size); + mem = xalloc(size); MEMSET(mem,c,size); } diff --git a/src/modules/system/nt.c b/src/modules/system/nt.c index 87ba4efaa5..25acdbfea9 100644 --- a/src/modules/system/nt.c +++ b/src/modules/system/nt.c @@ -1196,7 +1196,7 @@ static void low_encode_localgroup_members_info_0(LOCALGROUP_MEMBERS_INFO_0 *tmp) #define SAFE_PUSH_SID(X) do { \ if(getlengthsid && (X) && sid_program) { \ int lentmp=getlengthsid( (X) ); \ - PSID psidtmp=(PSID)xalloc(lentmp); \ + PSID psidtmp=xalloc(lentmp); \ struct object *o=low_clone(sid_program); \ MEMCPY( psidtmp, (X), lentmp); \ (*(PSID *)(o->storage))=psidtmp; \ @@ -2979,7 +2979,7 @@ static void f_LookupAccountName(INT32 args) if(sidlen && domainlen) { - PSID sid=(PSID)xalloc(sidlen); + PSID sid=xalloc(sidlen); struct pike_string *dom=begin_shared_string(domainlen-1); if(lookupaccountname(sys, @@ -3102,7 +3102,7 @@ static PACL decode_acl(struct array *arr) size += getlengthsid( *sid ) - sizeof(DWORD); } - ret=(PACL)xalloc( size ); + ret=xalloc( size ); if(!initializeacl(ret, size, ACL_REVISION)) Pike_error("InitializeAcl failed!\n"); @@ -3597,7 +3597,7 @@ static void f_sctx_create(INT32 args) sctx->cbMaxMessage = pkgInfo->cbMaxToken; if (sctx->buf) free(sctx->buf); - sctx->buf = (PBYTE)malloc(sctx->cbMaxMessage); + sctx->buf = malloc(sctx->cbMaxMessage); freecontextbuffer(pkgInfo); diff --git a/src/modules/system/system.c b/src/modules/system/system.c index f5ea96305b..4d381f290c 100644 --- a/src/modules/system/system.c +++ b/src/modules/system/system.c @@ -843,7 +843,7 @@ void f_setgroups(INT32 args) get_all_args("setgroups", args, "%a", &arr); if ((size = arr->size)) { - gids = (gid_t *)alloca(arr->size * sizeof(gid_t)); + gids = alloca(arr->size * sizeof(gid_t)); if (!gids) Pike_error("setgroups(): Too large array (%d).\n", arr->size); } else { gids = (gid_t *)safeguard; @@ -892,7 +892,7 @@ void f_getgroups(INT32 args) /* OS which doesn't understand this convention */ numgrps = NGROUPS_MAX; } - gids = (gid_t *)xalloc(sizeof(gid_t) * numgrps); + gids = xalloc(sizeof(gid_t) * numgrps); numgrps = getgroups(numgrps, gids); diff --git a/src/multiset.c b/src/multiset.c index 44fc0c63ae..1188b11b12 100644 --- a/src/multiset.c +++ b/src/multiset.c @@ -310,9 +310,9 @@ static struct multiset_data *low_alloc_multiset_data (int allocsize, int flags) Pike_fatal ("Allocating multiset data blocks within gc is not allowed.\n"); #endif - msd = (struct multiset_data *) xalloc ( - flags & MULTISET_INDVAL ? - NODE_OFFSET (msnode_indval, allocsize) : NODE_OFFSET (msnode_ind, allocsize)); + msd = xalloc ( flags & MULTISET_INDVAL ? + NODE_OFFSET (msnode_indval, allocsize) : + NODE_OFFSET (msnode_ind, allocsize) ); msd->refs = msd->noval_refs = 0; msd->root = NULL; msd->allocsize = allocsize; diff --git a/src/peep.c b/src/peep.c index 1fcdfdaf10..c5e06121b5 100644 --- a/src/peep.c +++ b/src/peep.c @@ -320,7 +320,7 @@ INT32 assemble(int store_linenumbers) if (c->opcode == F_ENTRY) c->opcode = F_NOP; #endif - labels=(INT32 *)xalloc(sizeof(INT32) * 4 * (max_label+2)); + labels=xalloc(sizeof(INT32) * 4 * (max_label+2)); jumps = labels + max_label + 2; uses = jumps + max_label + 2; aliases = uses + max_label + 2; diff --git a/src/post_modules/GTK1/source/support.c b/src/post_modules/GTK1/source/support.c index 4e9411ccf9..e85825c40f 100644 --- a/src/post_modules/GTK1/source/support.c +++ b/src/post_modules/GTK1/source/support.c @@ -455,7 +455,7 @@ void push_Xpseudo32bitstring( void *f, int nelems ) if( sizeof( long ) != 4 ) { long *q = (long *)f; - p_wchar2 *res = (p_wchar2 *)xalloc( nelems * 4 ), i; + p_wchar2 *res = xalloc( nelems * 4 ), i; for(i=0; i<nelems; i++ ) res[i] = q[i]; push_string( make_shared_binary_string2( res, nelems ) ); diff --git a/src/post_modules/GTK2/source/support.c b/src/post_modules/GTK2/source/support.c index 956fa7cb76..072eb7c4ae 100644 --- a/src/post_modules/GTK2/source/support.c +++ b/src/post_modules/GTK2/source/support.c @@ -437,7 +437,7 @@ void push_atom(GdkAtom a) { void push_Xpseudo32bitstring(void *f, int nelems) { if (sizeof(long)!=4) { long *q=(long *)f; - int *res=(int *)xalloc(nelems*4),i; + int *res=xalloc(nelems*4),i; for (i=0; i<nelems; i++) res[i]=q[i]; push_string(make_shared_binary_string2((const p_wchar2 *)res,nelems)); diff --git a/src/post_modules/Nettle/hash.cmod b/src/post_modules/Nettle/hash.cmod index 414a2d0e41..d78d6b0d9e 100644 --- a/src/post_modules/Nettle/hash.cmod +++ b/src/post_modules/Nettle/hash.cmod @@ -133,7 +133,7 @@ PIKECLASS Hash Pike_error("Hash not properly initialized.\n"); NO_WIDE_STRING(in); - ctx = (void *)alloca(meta->context_size); + ctx = alloca(meta->context_size); if(!ctx) SIMPLE_OUT_OF_MEMORY_ERROR("hash", meta->context_size); @@ -211,13 +211,11 @@ PIKECLASS Hash if (!S_ISREG(st.st_mode)) Pike_error("Non-regular file.\n"); - ctx = (void *)alloca(meta->context_size); + ctx = alloca(meta->context_size); if (!ctx) SIMPLE_OUT_OF_MEMORY_ERROR("hash", meta->context_size); - read_buffer=(char *)malloc(8192); - if (!read_buffer) - SIMPLE_OUT_OF_MEMORY_ERROR("hash", 8192); + read_buffer=xalloc(8192); THREADS_ALLOW(); meta->init(ctx); @@ -303,11 +301,11 @@ PIKECLASS Hash password->flags |= STRING_CLEAR_ON_EXIT; - ctx = (void *)alloca(meta->context_size); + ctx = alloca(meta->context_size); if (!ctx) SIMPLE_OUT_OF_MEMORY_ERROR("crypt_hash", meta->context_size); - abcbuf = (uint8_t *)alloca(meta->digest_size * 3); + abcbuf = alloca(meta->digest_size * 3); if (!abcbuf) SIMPLE_OUT_OF_MEMORY_ERROR("crypt_hash", meta->digest_size * 3); diff --git a/src/post_modules/Shuffler/a_source_pikestring.c b/src/post_modules/Shuffler/a_source_pikestring.c index f9e670cd31..69e649e3a0 100644 --- a/src/post_modules/Shuffler/a_source_pikestring.c +++ b/src/post_modules/Shuffler/a_source_pikestring.c @@ -61,7 +61,7 @@ struct source *source_pikestring_make( struct svalue *s, if( s->u.string->size_shift ) return 0; res = calloc( 1, sizeof( struct ps_source ) ); - if( !res ) retrun NULL; + if( !res ) return NULL; debug_malloc_touch( res ); debug_malloc_touch( s ); diff --git a/src/post_modules/_Image_WebP/image_webp.cmod b/src/post_modules/_Image_WebP/image_webp.cmod index e51a12b038..fbc8fb03a3 100644 --- a/src/post_modules/_Image_WebP/image_webp.cmod +++ b/src/post_modules/_Image_WebP/image_webp.cmod @@ -59,7 +59,7 @@ int WebPMemoryWrite(const uint8_t* data, size_t data_size, size_t next_max_size = 2ULL * w->max_size; if (next_max_size < next_size) next_max_size = next_size; if (next_max_size < 8192ULL) next_max_size = 8192ULL; - new_mem = (uint8_t*)xalloc(next_max_size); + new_mem = xalloc(next_max_size); if (w->size > 0) { memcpy(new_mem, w->mem, w->size); } @@ -399,7 +399,7 @@ PIKEFUN string encode( object i, if( image_width( a ) != width || image_height( a ) != height ) Pike_error("The alpha channel does not have the same size as the image\n"); - dst = rgba = (unsigned char*)xalloc( num * 4 ); + dst = rgba = xalloc( num * 4 ); while( num-- ) { diff --git a/src/signal_handler.c b/src/signal_handler.c index 94387fd9c2..b78b729013 100644 --- a/src/signal_handler.c +++ b/src/signal_handler.c @@ -3220,7 +3220,7 @@ void f_create_process(INT32 args) if (i) { /* Don't forget stdin, stdout, and stderr */ num_fds = i+3; - storage.fds = fds = (int *)xalloc(sizeof(int)*(num_fds)); + storage.fds = fds = xalloc(sizeof(int)*(num_fds)); fds[0] = fds[1] = fds[2] = -1; while (i--) { if (TYPEOF(a->item[i]) == T_OBJECT) { @@ -3389,7 +3389,7 @@ void f_create_process(INT32 args) i=mapping_indices(m); v=mapping_values(m); - storage.env=(char **)xalloc((1+m_sizeof(m)) * sizeof(char *)); + storage.env=xalloc((1+m_sizeof(m)) * sizeof(char *)); for(e=0;e<i->size;e++) { if(TYPEOF(ITEM(i)[e]) == T_STRING && diff --git a/src/stack_allocator.c b/src/stack_allocator.c index aec9b91c12..140b3fe613 100644 --- a/src/stack_allocator.c +++ b/src/stack_allocator.c @@ -2,7 +2,7 @@ MALLOC_FUNCTION static struct chunk * alloc_chunk(size_t size) { - struct chunk * c = (struct chunk*)xalloc(sizeof(struct chunk) + size); + struct chunk * c = xalloc(sizeof(struct chunk) + size); c->data = c->top = c + 1; c->size = size; c->prev = NULL; diff --git a/src/stralloc.c b/src/stralloc.c index 4b0b2ec28c..ea820ec86e 100644 --- a/src/stralloc.c +++ b/src/stralloc.c @@ -669,11 +669,11 @@ PMOD_EXPORT struct pike_string *debug_begin_shared_string(size_t len) #endif if (len <= SHORT_STRING_THRESHOLD) { - t=(struct pike_string *)ba_alloc(&string_allocator); + t=ba_alloc(&string_allocator); t->flags = STRING_NOT_HASHED | STRING_NOT_SHARED | STRING_IS_SHORT; } else { - t=(struct pike_string *)xalloc(len + 1 + sizeof(struct pike_string_hdr)); + t=xalloc(len + 1 + sizeof(struct pike_string_hdr)); t->flags = STRING_NOT_HASHED | STRING_NOT_SHARED; } #ifdef ATOMIC_SVALUE @@ -806,11 +806,10 @@ PMOD_EXPORT struct pike_string *debug_begin_wide_shared_string(size_t len, int s if (shift > 2) Pike_fatal("Unsupported string shift: %d\n", shift); #endif /* PIKE_DEBUG */ - t=(struct pike_string *)ba_alloc(&string_allocator); + t=ba_alloc(&string_allocator); t->flags = STRING_NOT_HASHED|STRING_NOT_SHARED|STRING_IS_SHORT; } else { - t=(struct pike_string *)xalloc(((len + 1)<<shift) + - sizeof(struct pike_string_hdr)); + t=xalloc(((len + 1)<<shift) + sizeof(struct pike_string_hdr)); t->flags = STRING_NOT_HASHED|STRING_NOT_SHARED; } #ifdef ATOMIC_SVALUE @@ -1733,9 +1732,7 @@ struct pike_string *realloc_unlinked_string(struct pike_string *a, return a; } } else { - r=(struct pike_string *)realloc((char *)a, - sizeof(struct pike_string_hdr)+ - ((size+1)<<a->size_shift)); + r=realloc(a, sizeof(struct pike_string_hdr)+((size+1)<<a->size_shift)); } if(!r) @@ -2229,7 +2226,7 @@ void init_shared_string_table(void) #ifdef PIKE_RUN_UNLOCKED { int h; - bucket_locks=(PIKE_MUTEX_T *)xalloc(sizeof(PIKE_MUTEX_T)*BUCKET_LOCKS); + bucket_locks=xalloc(sizeof(PIKE_MUTEX_T)*BUCKET_LOCKS); for(h=0;h<BUCKET_LOCKS;h++) mt_init(bucket_locks + h); } #endif -- GitLab