1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-05 23:20:38 +02:00

* gc.c (scm_mallocated): Just make this signed.

(scm_igc): Check for underflow by seeing if this is negative.
Much cleaner.
* gc.h (scm_mallocated): Fix declaration.
(Thanks to Greg Harvey.)
This commit is contained in:
Jim Blandy 1999-06-16 10:18:27 +00:00
parent d2ab9696bb
commit a5c314c80e
2 changed files with 10 additions and 14 deletions

View file

@ -175,7 +175,7 @@ SCM scm_weak_vectors;
/* GC Statistics Keeping /* GC Statistics Keeping
*/ */
unsigned long scm_cells_allocated = 0; unsigned long scm_cells_allocated = 0;
unsigned long scm_mallocated = 0; long scm_mallocated = 0;
unsigned long scm_gc_cells_collected; unsigned long scm_gc_cells_collected;
unsigned long scm_gc_malloc_collected; unsigned long scm_gc_malloc_collected;
unsigned long scm_gc_ports_collected; unsigned long scm_gc_ports_collected;
@ -454,17 +454,13 @@ scm_igc (what)
return; return;
} }
if (scm_mallocated > ((unsigned long) 0 - (1 << 24))) if (scm_mallocated < 0)
{ /* The byte count of allocated objects has underflowed. This is
/* It is extremely unlikely that you have allocated all but 16 Mb probably because you forgot to report the sizes of objects you
(one sixteenth of 2^32) of your address space. It is much more have allocated, by calling scm_done_malloc or some such. When
likely that you have forgotten to report the sizes of objects the GC freed them, it subtracted their size from
you have allocated via scm_done_malloc, or some such. When the scm_mallocated, which underflowed. */
GC freed them, it subtracted their size from scm_mallocated,
which underflowed. Since it's unsigned, this looks like a
really big number, so we start GC'ing all the time. */
abort (); abort ();
}
if (scm_gc_heap_lock) if (scm_gc_heap_lock)
/* We've invoked the collector while a GC is already in progress. /* We've invoked the collector while a GC is already in progress.

View file

@ -2,7 +2,7 @@
#ifndef GCH #ifndef GCH
#define GCH #define GCH
/* Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. /* Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -72,7 +72,7 @@ extern unsigned long scm_gc_cells_collected;
extern unsigned long scm_gc_malloc_collected; extern unsigned long scm_gc_malloc_collected;
extern unsigned long scm_gc_ports_collected; extern unsigned long scm_gc_ports_collected;
extern unsigned long scm_cells_allocated; extern unsigned long scm_cells_allocated;
extern unsigned long scm_mallocated; extern long scm_mallocated;
extern unsigned long scm_mtrigger; extern unsigned long scm_mtrigger;
#ifdef DEBUG_FREELIST #ifdef DEBUG_FREELIST