]> git.sur5r.net Git - cc65/commitdiff
Added xrealloc
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 26 Mar 2001 21:46:37 +0000 (21:46 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 26 Mar 2001 21:46:37 +0000 (21:46 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@677 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/common/xmalloc.c
src/common/xmalloc.h

index 7b1bd6e876296ac4055dae10a1d7a501a141ddf5..8b14d1ff5140003dcd29cdf85ca7d44fc3115408 100644 (file)
@@ -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 */
 {
index d90a5c9d3d871eb390d0291e6e333541b4679ff7..4a9597fadb495f8d4a4a40a07a8550bb16c76aac 100644 (file)
@@ -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 */