X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fdynarr.c;h=5dfc79d35e19f502463e40d4b96558a1cd8eeaf2;hb=ea48147f9be5f5c6797ebf3a8398c9741f23937f;hp=02f43437dea2f0239ccf4546a272b9d9cf2ce6e2;hpb=ea1ea793fe6e244ef5555ed983423a204101af13;p=chise%2Fxemacs-chise.git.1 diff --git a/src/dynarr.c b/src/dynarr.c index 02f4343..5dfc79d 100644 --- a/src/dynarr.c +++ b/src/dynarr.c @@ -101,15 +101,14 @@ Use the following functions/macros: Use the following global variable: Dynarr_min_size - Minimum allowable size for a dynamic array when it is resized. The - default is 32 and does not normally need to be changed. + Minimum allowable size for a dynamic array when it is resized. */ #include #include "lisp.h" -int Dynarr_min_size = 1; +static int Dynarr_min_size = 8; static void Dynarr_realloc (Dynarr *dy, int new_size) @@ -117,7 +116,8 @@ 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); + int max_bytes = dy->max * dy->elsize; + memcpy (new_base, dy->base, max_bytes > new_size ? new_size : max_bytes); dy->base = new_base; } else @@ -158,7 +158,7 @@ Dynarr_resize (void *d, int size) /* 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;