diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/client/client.c | 2 | ||||
-rw-r--r-- | source4/lib/util.c | 25 | ||||
-rw-r--r-- | source4/lib/util_file.c | 2 | ||||
-rw-r--r-- | source4/lib/util_strlist.c | 6 | ||||
-rw-r--r-- | source4/lib/wins_srv.c | 2 | ||||
-rw-r--r-- | source4/libcli/auth/gensec.c | 4 | ||||
-rw-r--r-- | source4/libcli/namequery.c | 7 | ||||
-rw-r--r-- | source4/ntvfs/common/brlock.c | 13 | ||||
-rw-r--r-- | source4/param/loadparm.c | 4 | ||||
-rw-r--r-- | source4/param/params.c | 6 | ||||
-rw-r--r-- | source4/smbd/process_model.c | 4 |
11 files changed, 25 insertions, 50 deletions
diff --git a/source4/client/client.c b/source4/client/client.c index 6af145c31e..e4a7dc7cb5 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -488,7 +488,7 @@ static void add_to_do_list_queue(const char* entry) do_list_queue_size *= 2; DEBUG(4,("enlarging do_list_queue to %d\n", (int)do_list_queue_size)); - dlq = Realloc(do_list_queue, do_list_queue_size); + dlq = realloc_p(do_list_queue, char, do_list_queue_size); if (! dlq) { d_printf("failure enlarging do_list_queue to %d bytes\n", (int)do_list_queue_size); diff --git a/source4/lib/util.c b/source4/lib/util.c index 2d149e6e3d..ac5124840e 100644 --- a/source4/lib/util.c +++ b/source4/lib/util.c @@ -216,31 +216,6 @@ void become_daemon(BOOL Fork) /**************************************************************************** - Expand a pointer to be a particular size. -****************************************************************************/ - -void *Realloc(void *p,size_t size) -{ - void *ret=NULL; - - if (size == 0) { - SAFE_FREE(p); - DEBUG(5,("Realloc asked for 0 bytes\n")); - return NULL; - } - - if (!p) - ret = (void *)malloc(size); - else - ret = (void *)realloc(p,size); - - if (!ret) - DEBUG(0,("Memory allocation error: failed to expand to %d bytes\n",(int)size)); - - return(ret); -} - -/**************************************************************************** Free memory, checks for NULL. Use directly SAFE_FREE() Exists only because we need to pass a function pointer somewhere --SSS diff --git a/source4/lib/util_file.c b/source4/lib/util_file.c index 1dbaf1147e..f9697fb337 100644 --- a/source4/lib/util_file.c +++ b/source4/lib/util_file.c @@ -172,7 +172,7 @@ char *fgets_slash(char *s2,int maxlen,XFILE *f) char *t; maxlen *= 2; - t = (char *)Realloc(s,maxlen); + t = realloc_p(s, char, maxlen); if (!t) { DEBUG(0,("fgets_slash: failed to expand buffer!\n")); SAFE_FREE(s); diff --git a/source4/lib/util_strlist.c b/source4/lib/util_strlist.c index a9198031a1..33f824dcf8 100644 --- a/source4/lib/util_strlist.c +++ b/source4/lib/util_strlist.c @@ -53,7 +53,7 @@ char **str_list_make(const char *string, const char *sep) while (next_token(&str, tok, sep, sizeof(tok))) { if (num == lsize) { lsize += S_LIST_ABS; - rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1))); + rlist = realloc_p(list, char *, lsize + 1); if (!rlist) { DEBUG(0,("str_list_make: Unable to allocate memory")); str_list_free(&list); @@ -94,7 +94,7 @@ BOOL str_list_copy(char ***dest, const char **src) while (src[num]) { if (num == lsize) { lsize += S_LIST_ABS; - rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1))); + rlist = realloc_p(list, char *, lsize + 1); if (!rlist) { DEBUG(0,("str_list_copy: Unable to re-allocate memory")); str_list_free(&list); @@ -302,7 +302,7 @@ int ipstr_list_parse(const char* ipstr_list, struct ipv4_addr** ip_list) break; /* prepare place for another in_addr structure */ - *ip_list = Realloc(*ip_list, (count + 1) * sizeof(struct ipv4_addr)); + *ip_list = realloc_p(*ip_list, struct ipv4_addr, count + 1); if (!*ip_list) return -1; (*ip_list)[count] = addr; diff --git a/source4/lib/wins_srv.c b/source4/lib/wins_srv.c index c9a5549cdc..094de8d6b0 100644 --- a/source4/lib/wins_srv.c +++ b/source4/lib/wins_srv.c @@ -238,7 +238,7 @@ char **wins_srv_tags(void) } /* add it to the list */ - ret = (char **)Realloc(ret, (count+2) * sizeof(char *)); + ret = realloc_p(ret, char *, count+2); ret[count] = strdup(t_ip.tag); if (!ret[count]) break; count++; diff --git a/source4/libcli/auth/gensec.c b/source4/libcli/auth/gensec.c index 3cf96de4b3..7243222b6d 100644 --- a/source4/libcli/auth/gensec.c +++ b/source4/libcli/auth/gensec.c @@ -770,7 +770,9 @@ NTSTATUS gensec_register(const void *_ops) return NT_STATUS_OBJECT_NAME_COLLISION; } - generic_security_ops = Realloc(generic_security_ops, sizeof(generic_security_ops[0]) * (gensec_num_backends+1)); + generic_security_ops = realloc_p(generic_security_ops, + const struct gensec_security_ops *, + gensec_num_backends+1); if (!generic_security_ops) { smb_panic("out of memory in gensec_register"); } diff --git a/source4/libcli/namequery.c b/source4/libcli/namequery.c index 66154ef8f6..76fffe0d92 100644 --- a/source4/libcli/namequery.c +++ b/source4/libcli/namequery.c @@ -400,11 +400,12 @@ struct ipv4_addr *name_query(int fd,const char *name,int name_type, continue; } - tmp_ip_list = (struct ipv4_addr *)Realloc( ip_list, sizeof( ip_list[0] ) - * ( (*count) + nmb2->answers->rdlength/6 ) ); + tmp_ip_list = realloc_p(ip_list, + struct ipv4_addr, + (*count) + nmb2->answers->rdlength/6); if (!tmp_ip_list) { - DEBUG(0,("name_query: Realloc failed.\n")); + DEBUG(0,("name_query: realloc_p failed.\n")); SAFE_FREE(ip_list); } diff --git a/source4/ntvfs/common/brlock.c b/source4/ntvfs/common/brlock.c index e01f458e74..7b351f77b0 100644 --- a/source4/ntvfs/common/brlock.c +++ b/source4/ntvfs/common/brlock.c @@ -229,9 +229,8 @@ NTSTATUS brl_lock(struct brl_context *brl, void *notify_ptr) { TDB_DATA kbuf, dbuf; - int count, i; - struct lock_struct lock, *locks; - char *tp; + int count=0, i; + struct lock_struct lock, *locks=NULL; NTSTATUS status; kbuf.dptr = (char *)file_key->data; @@ -279,14 +278,14 @@ NTSTATUS brl_lock(struct brl_context *brl, } /* no conflicts - add it to the list of locks */ - tp = Realloc(dbuf.dptr, dbuf.dsize + sizeof(*locks)); - if (!tp) { + locks = realloc_p(locks, struct lock_struct, count+1); + if (!locks) { status = NT_STATUS_NO_MEMORY; goto fail; } else { - dbuf.dptr = tp; + dbuf.dptr = (char *)locks; } - memcpy(dbuf.dptr + dbuf.dsize, &lock, sizeof(lock)); + locks[count] = lock; dbuf.dsize += sizeof(lock); if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) { diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index 1d9553de3e..8975f066fa 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -1568,9 +1568,7 @@ static int add_a_service(const service *pservice, const char *name) if (i == iNumServices) { service **tsp; - tsp = (service **) Realloc(ServicePtrs, - sizeof(service *) * - num_to_alloc); + tsp = realloc_p(ServicePtrs, service *, num_to_alloc); if (!tsp) { DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n")); diff --git a/source4/param/params.c b/source4/param/params.c index a31d8d1b60..1b5b02cfa3 100644 --- a/source4/param/params.c +++ b/source4/param/params.c @@ -239,7 +239,7 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *) ) { char *tb; - tb = Realloc( bufr, bSize +BUFR_INC ); + tb = realloc_p(bufr, char, bSize + BUFR_INC); if( NULL == tb ) { DEBUG(0, ("%s Memory re-allocation failure.", func) ); @@ -336,7 +336,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *) { char *tb; - tb = Realloc( bufr, bSize + BUFR_INC ); + tb = realloc_p( bufr, char, bSize + BUFR_INC ); if( NULL == tb ) { DEBUG(0, ("%s Memory re-allocation failure.", func) ); @@ -404,7 +404,7 @@ static BOOL Parameter( myFILE *InFile, BOOL (*pfunc)(const char *, const char *) { char *tb; - tb = Realloc( bufr, bSize + BUFR_INC ); + tb = realloc_p( bufr, char, bSize + BUFR_INC ); if( NULL == tb ) { DEBUG(0, ("%s Memory re-allocation failure.", func) ); diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c index 2a3efe2088..ad9a26d377 100644 --- a/source4/smbd/process_model.c +++ b/source4/smbd/process_model.c @@ -43,7 +43,7 @@ const struct model_ops *process_model_startup(const char *model) } /* the list of currently registered process models */ -static struct { +static struct process_model { struct model_ops *ops; } *models = NULL; static int num_models; @@ -65,7 +65,7 @@ NTSTATUS register_process_model(const void *_ops) return NT_STATUS_OBJECT_NAME_COLLISION; } - models = Realloc(models, sizeof(models[0]) * (num_models+1)); + models = realloc_p(models, struct process_model, num_models+1); if (!models) { smb_panic("out of memory in register_process_model"); } |