1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 14:21:10 +02:00

(scm_done_free): Always subtract size from scm_mallocated

when computing nm, even if it's negative.
(scm_must_malloc): Abort on overflow of scm_mtrigger.
(scm_must_realloc): Likewise.
This commit is contained in:
Marius Vollmer 2001-09-06 11:11:31 +00:00
parent 06288138ba
commit 5e7248f272

View file

@ -1059,8 +1059,6 @@ scm_igc (const char *what)
/* During the critical section, only the current thread may run. */ /* During the critical section, only the current thread may run. */
SCM_CRITICAL_SECTION_START; SCM_CRITICAL_SECTION_START;
/* fprintf (stderr, "gc: %s\n", what); */
if (!scm_stack_base || scm_block_gc) if (!scm_stack_base || scm_block_gc)
{ {
--scm_gc_running_p; --scm_gc_running_p;
@ -1985,11 +1983,15 @@ scm_must_malloc (size_t size, const char *what)
if (NULL != ptr) if (NULL != ptr)
{ {
scm_mallocated = nm; scm_mallocated = nm;
if (nm > scm_mtrigger - SCM_MTRIGGER_HYSTERESIS) { if (nm > scm_mtrigger - SCM_MTRIGGER_HYSTERESIS) {
unsigned long old_trigger = scm_mtrigger;
if (nm > scm_mtrigger) if (nm > scm_mtrigger)
scm_mtrigger = nm + nm / 2; scm_mtrigger = nm + nm / 2;
else else
scm_mtrigger += scm_mtrigger / 2; scm_mtrigger += scm_mtrigger / 2;
if (scm_mtrigger < old_trigger)
abort ();
} }
#ifdef GUILE_DEBUG_MALLOC #ifdef GUILE_DEBUG_MALLOC
scm_malloc_register (ptr, what); scm_malloc_register (ptr, what);
@ -2053,10 +2055,13 @@ scm_must_realloc (void *where,
{ {
scm_mallocated = nm; scm_mallocated = nm;
if (nm > scm_mtrigger - SCM_MTRIGGER_HYSTERESIS) { if (nm > scm_mtrigger - SCM_MTRIGGER_HYSTERESIS) {
unsigned long old_trigger = scm_mtrigger;
if (nm > scm_mtrigger) if (nm > scm_mtrigger)
scm_mtrigger = nm + nm / 2; scm_mtrigger = nm + nm / 2;
else else
scm_mtrigger += scm_mtrigger / 2; scm_mtrigger += scm_mtrigger / 2;
if (scm_mtrigger < old_trigger)
abort ();
} }
#ifdef GUILE_DEBUG_MALLOC #ifdef GUILE_DEBUG_MALLOC
scm_malloc_reregister (where, ptr, what); scm_malloc_reregister (where, ptr, what);
@ -2158,7 +2163,7 @@ scm_done_free (long size)
scm_mallocated, which underflowed. */ scm_mallocated, which underflowed. */
abort (); abort ();
} else { } else {
unsigned long nm = scm_mallocated + size; unsigned long nm = scm_mallocated - size;
if (nm < size) if (nm < size)
/* The byte count of allocated objects has overflowed. This is /* The byte count of allocated objects has overflowed. This is
probably because you forgot to report the correct size of freed probably because you forgot to report the correct size of freed