From: Hongli Lai Date: 2007-10-13T03:03:52+09:00 Subject: Question about heap_slots in gc.c I'm trying to modify the Ruby interpreter's garbage collector. At the moment I'm trying to understand the 'heap_slots' variable. Currently, heap_slots is used like this when add_heap() is called: 1. Allocate a new heap with size heap_slot + 1. 2. Increment heap_slot by 1, then by 80%. This means that next time a new heap is created, it will be larger. 3. If next time add_heap() is called, and heap allocation fails (possible because heap_size is too large now), then add_heap() will try again but with HEAP_MIN_SLOTS instead. If that fails too, then bail out. But this line caught my eye: if (heap_slots <= 0) heap_slots = HEAP_MIN_SLOTS; From what I understand, heap_slots can never be negative. Did I miss something? Why is the check there?