smalltalk-tng
diff experiments/hashconsing/hashcons.c @ 321:c4a0718c2d3c
Sketch of dependencies
| author | Tony Garnock-Jones <tonygarnockjones@gmail.com> |
|---|---|
| date | Sat Oct 08 15:36:03 2011 -0400 (7 months ago) |
| parents | c8f794195b31 |
| children |
line diff
1.1 --- a/experiments/hashconsing/hashcons.c Mon May 07 00:15:23 2007 +1200 1.2 +++ b/experiments/hashconsing/hashcons.c Sat Oct 08 15:36:03 2011 -0400 1.3 @@ -119,22 +119,26 @@ 1.4 sweep_heap(); 1.5 } 1.6 1.7 -static CONS alloc_pair(void) { 1.8 +static CONS gc_alloc_pair(void) { 1.9 + gc(); 1.10 + if (heap_next == NULL) { 1.11 + fprintf(stderr, "out of memory\n"); 1.12 + exit(3); 1.13 + } 1.14 + { 1.15 + CONS result = heap_next; 1.16 + heap_next = heap_next->next; 1.17 + return result; 1.18 + } 1.19 +} 1.20 + 1.21 +static inline CONS alloc_pair(void) { 1.22 if (heap_next != NULL) { 1.23 CONS result = heap_next; 1.24 heap_next = heap_next->next; 1.25 return result; 1.26 } else { 1.27 - gc(); 1.28 - if (heap_next == NULL) { 1.29 - fprintf(stderr, "out of memory\n"); 1.30 - exit(3); 1.31 - } 1.32 - { 1.33 - CONS result = heap_next; 1.34 - heap_next = heap_next->next; 1.35 - return result; 1.36 - } 1.37 + return gc_alloc_pair(); 1.38 } 1.39 } 1.40
