From e5ce904ddbd6175ba86ed827bf096b76b11b5511 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Dec 2004 06:42:06 +0000 Subject: r4054: got rid of Realloc(), replacing it with the type safe macro realloc_p() (This used to be commit b0f6e21481745d1b2ced28d9ed6f09f6ffd99562) --- source4/lib/util.c | 25 ------------------------- source4/lib/util_file.c | 2 +- source4/lib/util_strlist.c | 6 +++--- source4/lib/wins_srv.c | 2 +- 4 files changed, 5 insertions(+), 30 deletions(-) (limited to 'source4/lib') 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 @@ -215,31 +215,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() 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++; -- cgit