PATCH 21.5
Usually we worry more about buffers that are too small, I know.
However, there is no point in allocating and then iterating over memory
that will never be used. In lrecord.h is this declaration:
extern MODULE_API const struct lrecord_implementation *
lrecord_implementations_table[lrecord_type_last_built_in_type +
MODULE_DEFINABLE_TYPE_COUNT];
which means that countof (lrecord_implementations_table) ==
lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT, so there
is no point in adding MODULE_DEFINABLE_TYPE_COUNT on yet again in the
expressions in alloc.c. This patch removes the extra
MODULE_DEFINABLE_TYPE_COUNT.
Note that this still leaves the stats arrays with extra room. Both
lrecord_stats and lcrecord_stats have slots for every possible type,
even though a given type will appear in only one of the two.
src/ChangeLog addition:
2006-06-16 Jerry James <james(a)xemacs.org>
* alloc.c: Don't add MODULE_DEFINABLE_TYPE_COUNT to
countof (lrecord_implementations_table); the latter is already big
enough.
xemacs-21.5 source patch:
Diff command: cvs -q diff -uN
Files affected: src/alloc.c
Index: src/alloc.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/alloc.c,v
retrieving revision 1.126
diff -d -u -r1.126 alloc.c
--- src/alloc.c 2006/04/23 20:12:31 1.126
+++ src/alloc.c 2006/06/16 16:53:53
@@ -508,8 +508,7 @@
int instances_in_use;
int bytes_in_use;
int bytes_in_use_including_overhead;
-} lrecord_stats [countof (lrecord_implementations_table)
- + MODULE_DEFINABLE_TYPE_COUNT];
+} lrecord_stats [countof (lrecord_implementations_table)];
void
init_lrecord_stats ()
@@ -554,8 +553,7 @@
{
int i;
int size = 0;
- for (i = 0; i < (countof (lrecord_implementations_table)
- + MODULE_DEFINABLE_TYPE_COUNT); i++)
+ for (i = 0; i < countof (lrecord_implementations_table); i++)
size += lrecord_stats[i].bytes_in_use;
return size;
}
@@ -3433,8 +3431,7 @@
int instances_freed;
int bytes_freed;
int instances_on_free_list;
-} lcrecord_stats [countof (lrecord_implementations_table)
- + MODULE_DEFINABLE_TYPE_COUNT];
+} lcrecord_stats [countof (lrecord_implementations_table)];
static void
tick_lcrecord_stats (const struct lrecord_header *h, int free_p)
@@ -4428,8 +4425,7 @@
#ifdef NEW_GC
- for (i = 0; i < (countof (lrecord_implementations_table)
- + MODULE_DEFINABLE_TYPE_COUNT); i++)
+ for (i = 0; i < countof (lrecord_implementations_table); i++)
{
if (lrecord_stats[i].instances_in_use != 0)
{
--
Jerry James, Assistant Professor james(a)xemacs.org
Computer Science Department
http://www.cs.usu.edu/~jerry/
Utah State University