summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-12-03 06:42:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:06:19 -0500
commite5ce904ddbd6175ba86ed827bf096b76b11b5511 (patch)
tree722b04d001e9b26bb47b2480fef13699a0366667 /source4/lib
parent7dcfd94f817d1c12a14704cbb96604dc3074aa2e (diff)
downloadsamba-e5ce904ddbd6175ba86ed827bf096b76b11b5511.tar.gz
samba-e5ce904ddbd6175ba86ed827bf096b76b11b5511.tar.bz2
samba-e5ce904ddbd6175ba86ed827bf096b76b11b5511.zip
r4054: got rid of Realloc(), replacing it with the type safe macro realloc_p()
(This used to be commit b0f6e21481745d1b2ced28d9ed6f09f6ffd99562)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/util.c25
-rw-r--r--source4/lib/util_file.c2
-rw-r--r--source4/lib/util_strlist.c6
-rw-r--r--source4/lib/wins_srv.c2
4 files changed, 5 insertions, 30 deletions
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++;