diff src/dynarr.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents 74fd4e045ea6
children 11054d720c21
line wrap: on
line diff
--- a/src/dynarr.c	Mon Aug 13 11:19:22 2007 +0200
+++ b/src/dynarr.c	Mon Aug 13 11:20:41 2007 +0200
@@ -101,27 +101,15 @@
 Use the following global variable:
 
    Dynarr_min_size
-      Minimum allowable size for a dynamic array when it is resized.
+      Minimum allowable size for a dynamic array when it is resized.  The
+      default is 32 and does not normally need to be changed.
 
 */
 
 #include <config.h>
 #include "lisp.h"
 
-static int Dynarr_min_size = 8;
-
-static void
-Dynarr_realloc (Dynarr *dy, int new_size)
-{
-  if (DUMPEDP (dy->base))
-    {
-      void *new_base = malloc (new_size);
-      memcpy (new_base, dy->base, dy->max > new_size ? new_size : dy->max);
-      dy->base = new_base;
-    }
-  else
-    dy->base = xrealloc (dy->base, new_size);
-}
+int Dynarr_min_size = 1;
 
 void *
 Dynarr_newf (int elsize)
@@ -150,14 +138,14 @@
   /* Don't do anything if the array is already big enough. */
   if (newsize > dy->max)
     {
-      Dynarr_realloc (dy, newsize*dy->elsize);
+      dy->base = xrealloc (dy->base, newsize*dy->elsize);
       dy->max = newsize;
     }
 }
 
 /* Add a number of contiguous elements to the array starting at START. */
 void
-Dynarr_insert_many (void *d, const void *el, int len, int start)
+Dynarr_insert_many (void *d, CONST void *el, int len, int start)
 {
   Dynarr *dy = (Dynarr *) d;
 
@@ -198,10 +186,9 @@
 {
   Dynarr *dy = (Dynarr *) d;
 
-  if (dy->base && !DUMPEDP (dy->base))
+  if (dy->base)
     xfree (dy->base);
-  if(!DUMPEDP (dy))
-    xfree (dy);
+  xfree (dy);
 }
 
 #ifdef MEMORY_USAGE_STATS