chiark / gitweb /
New macros @DA_FIRST@ and @DA_LAST@ for stack/queue peeking.
[mLib] / alloc.c
diff --git a/alloc.c b/alloc.c
index d425e97573b9f9c718add5cb9a0ccaf35b9e7dd7..9bc536e78a0f1fa11d2a8e96dda7577552023768 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: alloc.c,v 1.4 2000/06/17 10:35:51 mdw Exp $
+ * $Id: alloc.c,v 1.5 2000/07/16 12:29:16 mdw Exp $
  *
  * Memory allocation functions
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: alloc.c,v $
+ * Revision 1.5  2000/07/16 12:29:16  mdw
+ * Change to arena `realloc' interface, to fix a design bug.
+ *
  * Revision 1.4  2000/06/17 10:35:51  mdw
  * Major overhaul for arena support.
  *
@@ -104,6 +107,7 @@ char *x_strdup(arena *a, const char *s)
  * Arguments:  @arena *a@ = pointer to underlying arena
  *             @void *p@ = pointer to a block of memory
  *             @size_t sz@ = new size desired for the block
+ *             @size_t osz@ = size of the old block
  *
  * Returns:    Pointer to the resized memory block (which is almost
  *             certainly not in the same place any more).
@@ -112,9 +116,9 @@ char *x_strdup(arena *a, const char *s)
  *             exception @EXC_NOMEM@ is thrown.
  */
 
-void *x_realloc(arena *a, void *p, size_t sz)
+void *x_realloc(arena *a, void *p, size_t sz, size_t osz)
 {
-  p = A_REALLOC(a, p, sz);
+  p = A_REALLOC(a, p, sz, osz);
   if (!p)
     THROW(EXC_NOMEM);
   return (p);
@@ -163,6 +167,7 @@ char *(xstrdup)(const char *s) { return xstrdup(s); }
  *
  * Arguments:  @void *p@ = pointer to a block of memory
  *             @size_t sz@ = new size desired for the block
+ *             @size_t osz@ = size of the old block
  *
  * Returns:    Pointer to the resized memory block (which is almost
  *             certainly not in the same place any more).
@@ -171,7 +176,8 @@ char *(xstrdup)(const char *s) { return xstrdup(s); }
  *             exception @EXC_NOMEM@ is thrown.
  */
 
-void *(xrealloc)(void *p, size_t sz) { return xrealloc(p, sz); }
+void *(xrealloc)(void *p, size_t sz, size_t osz)
+{ return xrealloc(p, sz, osz); }
 
 /* --- @xfree@ --- *
  *