From: cuz Date: Mon, 26 Mar 2001 21:46:37 +0000 (+0000) Subject: Added xrealloc X-Git-Tag: V2.12.0~2885 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1ced0327ed099228991af579f8b2e30c07f3ebdb;p=cc65 Added xrealloc git-svn-id: svn://svn.cc65.org/cc65/trunk@677 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/common/xmalloc.c b/src/common/xmalloc.c index 7b1bd6e87..8b14d1ff5 100644 --- a/src/common/xmalloc.c +++ b/src/common/xmalloc.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2000-2001 Ullrich von Bassewitz */ +/* Wacholderweg 14 */ +/* D-70597 Stuttgart */ +/* EMail: uz@musoftware.de */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -64,6 +64,23 @@ void* xmalloc (size_t Size) +void* xrealloc (void* P, size_t Size) +/* Reallocate a memory block, check for out of memory */ +{ + /* Reallocate the block */ + void* N = realloc (P, Size); + + /* Check for errors */ + if (N == 0 && Size != 0) { + AbEnd ("Out of memory in realloc - requested block size = %lu", (unsigned long) Size); + } + + /* Return the pointer to the new block */ + return N; +} + + + void xfree (const void* Block) /* Free the block, do some debugging */ { diff --git a/src/common/xmalloc.h b/src/common/xmalloc.h index d90a5c9d3..4a9597fad 100644 --- a/src/common/xmalloc.h +++ b/src/common/xmalloc.h @@ -51,6 +51,9 @@ void* xmalloc (size_t Size); /* Allocate memory, check for out of memory condition. Do some debugging */ +void* xrealloc (void* P, size_t Size); +/* Reallocate a memory block, check for out of memory */ + void xfree (const void* Block); /* Free the block, do some debugging */