/* -*-c-*-
*
- * $Id: darray.c,v 1.1 1999/10/22 22:37:26 mdw Exp $
+ * $Id: darray.c,v 1.2 1999/10/28 22:05:28 mdw Exp $
*
* Dynamically growing dense arrays
*
/*----- Revision history --------------------------------------------------*
*
* $Log: darray.c,v $
+ * Revision 1.2 1999/10/28 22:05:28 mdw
+ * Modify and debug allocation routines.
+ *
* Revision 1.1 1999/10/22 22:37:26 mdw
* New dynamic array implementation replaces `dynarray.h'.
*
/*----- Magic numbers -----------------------------------------------------*/
-#define DA_INITSZ 64 /* Default size for new array */
+#define DA_INITSZ 16 /* Default size for new array */
#define DA_SLOTS 8 /* Number of preshifted slots */
/*----- Main code ---------------------------------------------------------*/
/* --- Reallocate the array --- */
- nsz = v ? b->sz + b->off : DA_INITSZ;
+ nsz = v ? b->sz + b->off : (DA_INITSZ >> 1);
do nsz <<= 1; while (nsz < rq);
q = xmalloc(nsz * sz);
q += slots * sz;
/* --- Reallocate the array --- */
- nsz = v ? b->sz + b->off : DA_INITSZ;
+ nsz = v ? b->sz + b->off : (DA_INITSZ >> 1);
do nsz <<= 1; while (nsz < rq);
q = xmalloc(nsz * sz);
q += (nsz - slots) * sz;