diff options
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 35 |
1 files changed, 17 insertions, 18 deletions
@@ -6,7 +6,7 @@ $Date$ created at: Tue Oct 5 09:44:46 JST 1993 - Copyright (C) 1993-1999 Yukihiro Matsumoto + Copyright (C) 1993-2000 Yukihiro Matsumoto ************************************************/ @@ -50,7 +50,6 @@ static unsigned long malloc_memories = 0; static unsigned long alloc_objects = 0; static int malloc_called = 0; -static int free_called = 0; #ifndef xmalloc void * @@ -115,12 +114,11 @@ xrealloc(ptr, size) return mem; } -static void +void xfree(x) void *x; { - free_called++; - free(x); + if (x) free(x); } #endif @@ -242,8 +240,8 @@ add_heap() /* Realloc heaps */ heaps_length += HEAPS_INCREMENT; heaps = (heaps_used>0)? - (RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE)): - (RVALUE**)malloc(heaps_length*sizeof(RVALUE)); + (RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE*)): + (RVALUE**)malloc(heaps_length*sizeof(RVALUE*)); if (heaps == 0) rb_fatal("can't alloc memory"); } @@ -370,7 +368,7 @@ rb_mark_tbl(tbl) static int mark_hashentry(key, value) - ID key; + VALUE key; VALUE value; { rb_gc_mark(key); @@ -860,6 +858,9 @@ _rb_setjmp: movem.l d3-d7/a3-a5,(a0) moveq.l #0,d0 rts"); +#ifdef setjmp +#undef setjmp +#endif #else #if defined(DJGPP) typedef unsigned long rb_jmp_buf[6]; @@ -893,6 +894,11 @@ rb_gc() jmp_buf save_regs_gc_mark; #ifdef C_ALLOCA VALUE stack_end; + alloca(0); +# define STACK_END (&stack_end) +#else + VALUE *stack_end = alloca(1); +# define STACK_END (stack_end) #endif alloc_objects = 0; @@ -901,10 +907,6 @@ rb_gc() if (during_gc) return; during_gc++; -#ifdef C_ALLOCA - alloca(0); -#endif - /* mark frame stack */ for (frame = ruby_frame; frame; frame = frame->prev) { rb_gc_mark_frame(frame); @@ -924,18 +926,14 @@ rb_gc() /* This assumes that all registers are saved into the jmp_buf */ setjmp(save_regs_gc_mark); mark_locations_array((VALUE*)save_regs_gc_mark, sizeof(save_regs_gc_mark) / sizeof(VALUE *)); -#ifdef C_ALLOCA - rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)&stack_end); -#else - rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)alloca(1)); -#endif + rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END); #if defined(THINK_C) || defined(__human68k__) #ifndef __human68k__ mark_locations_array((VALUE*)((char*)save_regs_gc_mark+2), sizeof(save_regs_gc_mark) / sizeof(VALUE *)); #endif rb_gc_mark_locations((VALUE*)((char*)rb_gc_stack_start + 2), - (VALUE*)((char*)&stack_end + 2)); + (VALUE*)((char*)STACK_END + 2)); #endif rb_gc_mark_threads(); @@ -943,6 +941,7 @@ rb_gc() for (list = Global_List; list; list = list->next) { rb_gc_mark(*list->varptr); } + rb_mark_end_proc(); rb_gc_mark_global_tbl(); rb_mark_tbl(rb_class_tbl); |