Mercurial > hg > xemacs-beta
changeset 3210:72b7d685c194
[xemacs-hg @ 2006-01-20 17:59:48 by crestani]
* dynarr.c (Dynarr_realloc): Determine size of memory region to
copy correctly, fix types.
* dynarr.c (Dynarr_lisp_realloc): Determine size of memory region
to copy correctly.
* dynarr.c (Dynarr_resize): Call Dynarr_realloc with number of
elements instead of memory region size.
author | crestani |
---|---|
date | Fri, 20 Jan 2006 17:59:50 +0000 |
parents | 948bd302ca41 |
children | b16c0b10f097 |
files | src/ChangeLog src/dynarr.c |
diffstat | 2 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Fri Jan 20 17:50:46 2006 +0000 +++ b/src/ChangeLog Fri Jan 20 17:59:50 2006 +0000 @@ -1,3 +1,12 @@ +2006-01-19 Marcus Crestani <crestani@xemacs.org> + + * dynarr.c (Dynarr_realloc): Determine size of memory region to + copy correctly, fix types. + * dynarr.c (Dynarr_lisp_realloc): Determine size of memory region + to copy correctly. + * dynarr.c (Dynarr_resize): Call Dynarr_realloc with number of + elements instead of memory region size. + 2006-01-19 Marcus Crestani <crestani@xemacs.org> * objects-x.c (x_find_charset_font): Add cast to fix C++ build.
--- a/src/dynarr.c Fri Jan 20 17:50:46 2006 +0000 +++ b/src/dynarr.c Fri Jan 20 17:59:50 2006 +0000 @@ -129,16 +129,17 @@ static int Dynarr_min_size = 8; static void -Dynarr_realloc (Dynarr *dy, Bytecount new_size) +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 ? dy->max : new_size); + memcpy (new_base, dy->base, + (dy->max < new_size ? dy->max : new_size) * dy->elsize); dy->base = new_base; } else - dy->base = xrealloc (dy->base, new_size); + dy->base = xrealloc (dy->base, new_size * dy->elsize); } void * @@ -158,13 +159,13 @@ Dynarr); static void -Dynarr_lisp_realloc (Dynarr *dy, Elemcount new_size) +Dynarr_lisp_realloc (Dynarr *dy, int new_size) { void *new_base = alloc_lrecord_array (dy->elsize, new_size, dy->lisp_imp); void *old_base = dy->base; if (dy->base) memcpy (new_base, dy->base, - (dy->max > new_size ? dy->max : new_size) * dy->elsize); + (dy->max < new_size ? dy->max : new_size) * dy->elsize); dy->base = new_base; if (old_base) mc_free (old_base); @@ -205,9 +206,9 @@ if (dy->lisp_imp) Dynarr_lisp_realloc (dy, newsize); else - Dynarr_realloc (dy, newsize*dy->elsize); + Dynarr_realloc (dy, newsize); #else /* not NEW_GC */ - Dynarr_realloc (dy, newsize*dy->elsize); + Dynarr_realloc (dy, newsize); #endif /* not NEW_GC */ dy->max = newsize; }