Sun, 03 Nov 2002 03:09:04 +0100
trunk: changeset 44
remalloczero changes
misc.c | file | annotate | diff | comparison | revisions |
--- a/misc.c Mon May 27 00:27:30 2002 +0200 +++ b/misc.c Sun Nov 03 03:09:04 2002 +0100 @@ -28,22 +28,14 @@ void *p=NULL; if(newsize!=0){ - p=malloc(newsize); - + p=realloc(ptr, newsize); + if(p==NULL) return NULL; - memset(p, 0, newsize); - - if(newsize<oldsize) - oldsize=newsize; - - if(ptr!=NULL) - memcpy(p, ptr, oldsize); + if(newsize>oldsize) + memset(p+oldsize, 0, newsize-oldsize); } - - if(ptr!=NULL) - free(ptr); return p; }