From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/lib/util_str.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'source3/lib/util_str.c') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index a758aece4c..c6b6570f5c 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -134,7 +134,7 @@ char **toktocliplist(int *ctok, const char *sep) *ctok=ictok; s=(char *)last_ptr; - if (!(ret=iret=malloc((ictok+1)*sizeof(char *)))) + if (!(ret=iret=SMB_MALLOC_ARRAY(char *,ictok+1))) return NULL; while(ictok--) { @@ -815,7 +815,7 @@ void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) int i; char *hex_buffer; - *out_hex_buffer = smb_xmalloc((len*2)+1); + *out_hex_buffer = SMB_XMALLOC_ARRAY(char, (len*2)+1); hex_buffer = *out_hex_buffer; for (i = 0; i < len; i++) @@ -863,7 +863,7 @@ static BOOL string_init(char **dest,const char *src) if (l == 0) { if (!null_string) { - if((null_string = (char *)malloc(1)) == NULL) { + if((null_string = (char *)SMB_MALLOC(1)) == NULL) { DEBUG(0,("string_init: malloc fail for null_string.\n")); return False; } @@ -871,7 +871,7 @@ static BOOL string_init(char **dest,const char *src) } *dest = null_string; } else { - (*dest) = strdup(src); + (*dest) = SMB_STRDUP(src); if ((*dest) == NULL) { DEBUG(0,("Out of memory in string_init\n")); return False; @@ -990,7 +990,7 @@ char *realloc_string_sub(char *string, const char *pattern, const char *insert) s = string; - in = strdup(insert); + in = SMB_STRDUP(insert); if (!in) { DEBUG(0, ("realloc_string_sub: out of memory!\n")); return NULL; @@ -1019,7 +1019,7 @@ char *realloc_string_sub(char *string, const char *pattern, const char *insert) while ((p = strstr_m(s,pattern))) { if (ld > 0) { int offset = PTR_DIFF(s,string); - char *t = Realloc(string, ls + ld + 1); + char *t = SMB_REALLOC(string, ls + ld + 1); if (!t) { DEBUG(0, ("realloc_string_sub: out of memory!\n")); SAFE_FREE(in); @@ -1110,7 +1110,7 @@ static smb_ucs2_t *all_string_sub_w(const smb_ucs2_t *s, const smb_ucs2_t *patte } } - r = rp = (smb_ucs2_t *)malloc((lt + 1)*(sizeof(smb_ucs2_t))); + r = rp = SMB_MALLOC_ARRAY(smb_ucs2_t, lt + 1); if (!r) { DEBUG(0, ("all_string_sub_w: out of memory!\n")); return NULL; @@ -1478,7 +1478,7 @@ char *binary_string(char *buf, int len) char *s; int i, j; const char *hex = "0123456789ABCDEF"; - s = malloc(len * 3 + 1); + s = SMB_MALLOC(len * 3 + 1); if (!s) return NULL; for (j=i=0;i