From 1ced0327ed099228991af579f8b2e30c07f3ebdb Mon Sep 17 00:00:00 2001 From: cuz Date: Mon, 26 Mar 2001 21:46:37 +0000 Subject: [PATCH] Added xrealloc git-svn-id: svn://svn.cc65.org/cc65/trunk@677 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/common/xmalloc.c | 25 +++++++++++++++++++++---- src/common/xmalloc.h | 3 +++ 2 files changed, 24 insertions(+), 4 deletions(-) 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 */ -- 2.39.5