Friday, 20 January
2006
Fri, 20 Jan
'06
5:59 p.m.
User: crestani
Date: 06/01/20 18:59:52
Modified: xemacs/src ChangeLog dynarr.c
Log:
* 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.
Revision Changes Path
1.919 +9 -0 XEmacs/xemacs/src/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.918
retrieving revision 1.919
diff -u -p -r1.918 -r1.919
--- ChangeLog 2006/01/20 17:50:44 1.918
+++ ChangeLog 2006/01/20 17:59:48 1.919
@@ -1,5 +1,14 @@
2006-01-19 Marcus Crestani <crestani(a)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(a)xemacs.org>
+
* objects-x.c (x_find_charset_font): Add cast to fix C++ build.
2005-11-25 Mike Sperber <mike(a)xemacs.org>
1.14 +8 -7 XEmacs/xemacs/src/dynarr.c
Index: dynarr.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/dynarr.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- dynarr.c 2005/11/25 01:41:59 1.13
+++ dynarr.c 2006/01/20 17:59:50 1.14
@@ -129,16 +129,17 @@ Use the following global variable:
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 @@ DEFINE_LRECORD_IMPLEMENTATION ("dynarr",
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 @@ Dynarr_resize (void *d, Elemcount size)
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;
}
Show replies by date