pike.git/
src/
gc.c
Branch:
Tag:
Non-build tags
All tags
No tags
2000-09-04
2000-09-04 23:08:33 by Henrik Grubbström (Grubba) <grubba@grubba.org>
66ac547da7f8b26de2337a86dfe9ac17f2f72313 (
43
lines) (+
30
/-
13
)
[
Show
|
Annotate
]
Branch:
7.9
Fixed a few warnings.
Rev: src/gc.c:1.132
30:
#include "block_alloc.h"
-
RCSID("$Id: gc.c,v 1.
131
2000/09/04
14
:
28:
08 grubba Exp $");
+
RCSID("$Id: gc.c,v 1.
132
2000/09/04
23
:
08
:
33
grubba Exp $");
/* Run garbage collect approximately every time * 20 percent of all arrays, objects and programs is
1860:
return !(m->flags & GC_LIVE); }
+
static void free_obj_arr(void *oa)
+
{
+
struct array *obj_arr = *((struct array **)oa);
+
+
if (obj_arr) free_array(obj_arr);
+
free(oa);
+
}
+
static void warn_bad_cycles() {
-
JMP
_
BUF
uwp;
-
struct array *obj_arr =
0
;
+
/* The reason for the extra level of indirection, is that it might
+
* be clobbered by the longjump() in SET
_
ONERROR
otherwise.
+
* (On some architectures longjump() might restore obj_arr's original
+
* value (eg if obj_arr is in a register)).
+
*/
+
struct array *
*
obj_arr
_
=
(struct array **)xalloc(sizeof(struct array *))
;
+
ONERROR tmp;
-
if
(
!SETJMP(uwp
)
)
{
+
*obj_arr_
= NULL;
+
+
SET_ONERROR
(
tmp, free_obj_arr, obj_arr_
)
;
+
+
{
struct gc_frame *p; unsigned cycle = 0;
-
obj_arr = allocate_array(0);
+
*
obj_arr
_
= allocate_array(0);
for (p = kill_list; p;) { if ((cycle = CYCLE(p))) { push_object((struct object *) p->data);
-
obj_arr = append_array(obj_arr, --sp);
+
*
obj_arr
_
= append_array(
*
obj_arr
_
, --sp);
} p = NEXT(p); if (p ? ((unsigned)(CYCLE(p) != cycle)) : cycle) {
-
if (obj_arr->size >= 2) {
+
if (
(*
obj_arr
_)
->size >= 2) {
push_constant_text("gc"); push_constant_text("bad_cycle");
-
push_array(obj_arr);
-
obj_arr = 0;
+
push_array(
*
obj_arr
_
);
+
*
obj_arr
_
= 0;
SAFE_APPLY_MASTER("runtime_warning", 3); pop_stack();
-
obj_arr = allocate_array(0);
+
*
obj_arr
_
= allocate_array(0);
}
-
else obj_arr = resize_array(obj_arr, 0);
+
else
*
obj_arr
_
= resize_array(
*
obj_arr
_
, 0);
} if (!p) break; } }
-
UNSETJMP(uwp);
-
if (obj
_
arr) free
_
array(obj
_
arr
);
+
CALL
_
AND
_
UNSET_ONERROR
(
tmp
);
} int do_gc(void)