(debugging_realloc): Removed the assert for the NULL pointer, since
realloc() can take a NULL pointer, as defined by the realloc() man page. Fixed the cast in both safefree() macros to compile cleaning using a C++ compiler.
This commit is contained in:
parent
5a2af49e58
commit
bc77dfb492
@ -1,4 +1,4 @@
|
|||||||
/* $Id: heap.c,v 1.6 2003-06-26 18:14:13 rjkaes Exp $
|
/* $Id: heap.c,v 1.7 2003-07-31 23:42:51 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Debugging versions of various heap related functions are combined
|
* Debugging versions of various heap related functions are combined
|
||||||
* here. The debugging versions include assertions and also print
|
* here. The debugging versions include assertions and also print
|
||||||
@ -55,7 +55,6 @@ debugging_realloc(void *ptr, size_t size, const char *file, unsigned long line)
|
|||||||
{
|
{
|
||||||
void *newptr;
|
void *newptr;
|
||||||
|
|
||||||
assert(ptr != NULL);
|
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
|
|
||||||
newptr = realloc(ptr, size);
|
newptr = realloc(ptr, size);
|
||||||
@ -83,7 +82,7 @@ debugging_strdup(const char* s, const char* file, unsigned long line)
|
|||||||
assert(s != NULL);
|
assert(s != NULL);
|
||||||
|
|
||||||
len = strlen(s) + 1;
|
len = strlen(s) + 1;
|
||||||
ptr = malloc(len);
|
ptr = (char*)malloc(len);
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
memcpy(ptr, s, len);
|
memcpy(ptr, s, len);
|
||||||
|
Loading…
Reference in New Issue
Block a user