comparison src/lib/data-stack.c @ 9459:acfef2f0fec3 HEAD

data stack: Fixes to handling out-of-memory situations.
author Timo Sirainen <tss@iki.fi>
date Wed, 28 Oct 2009 14:10:45 -0400
parents fc8f3f5a7548
children 00cd9aacd03c
comparison
equal deleted inserted replaced
9458:adee8cb3ff5d 9459:acfef2f0fec3
67 static bool clean_after_pop = FALSE; 67 static bool clean_after_pop = FALSE;
68 static bool outofmem = FALSE; 68 static bool outofmem = FALSE;
69 69
70 static union { 70 static union {
71 struct stack_block block; 71 struct stack_block block;
72 unsigned char data[128]; 72 unsigned char data[512];
73 } outofmem_area; 73 } outofmem_area;
74 74
75 static void data_stack_last_buffer_reset(bool preserve_data ATTR_UNUSED) 75 static void data_stack_last_buffer_reset(bool preserve_data ATTR_UNUSED)
76 { 76 {
77 if (last_buffer_block != NULL) { 77 if (last_buffer_block != NULL) {
167 free(unused_block); 167 free(unused_block);
168 #endif 168 #endif
169 unused_block = block; 169 unused_block = block;
170 } else { 170 } else {
171 #ifndef USE_GC 171 #ifndef USE_GC
172 free(block); 172 if (block != &outofmem_area.block)
173 free(block);
173 #endif 174 #endif
174 } 175 }
175 176
176 block = next; 177 block = next;
177 } 178 }