on master help sign in
Clean up attr_alloc a bit
commitfdd831a33ce1c5aea5696f354be2eb225aa62a46 authorNeil Mitchell <ndmitchell@gmail.com> dateThu 4 Jan 2018, 12:27 (9 years ago) parent48395be
1 file changed+3−1
gen/test.c+3−1
gen/test.c+3−1
@@ -228,7 +228,9 @@ static inline void node_alloc(node_buffer* b, int ask)
228228
229229static inline attr* attr_alloc(attr_buffer* b)
230230{
231− if (b->size <= b->used)
231+ // Ensure there is at least one node left
232+ int space = b->size - b->used;
233+ if (space < 1)
232234 {
233235 int size2 = (b->size + 1000) * 2;
234236 attr* buf2 = malloc(size2 * sizeof(attr));