on master help sign in
Clean up attr_alloc a bit
fdd831aNeil Mitchell
gen/test.c+3−1
@@ -228,7 +228,9 @@ static inline void node_alloc(node_buffer* b, int ask)
228
228
229static inline attr* attr_alloc(attr_buffer* b)
229static inline attr* attr_alloc(attr_buffer* b)
230{
230{
231+ // Ensure there is at least one node left
231− if (b->size <= b->used)
232+ int space = b->size - b->used;
233+ if (space < 1)
232 {
234 {
233 int size2 = (b->size + 1000) * 2;
235 int size2 = (b->size + 1000) * 2;
234 attr* buf2 = malloc(size2 * sizeof(attr));
236 attr* buf2 = malloc(size2 * sizeof(attr));