viric@2: #include viric@2: #include viric@2: #include "dictre.h" viric@2: viric@2: static int given = 0; viric@2: static int sysallocated = 0; viric@2: static void *base = 0; viric@2: viric@2: enum { viric@2: STEP = 5*1024*1024 viric@2: }; viric@2: viric@2: void * fastmalloc(int newsize) viric@2: { viric@2: void *outptr; viric@5: int old_given = given; viric@2: viric@2: given += newsize; viric@2: viric@2: if (given > sysallocated) viric@2: { viric@2: if (STEP > newsize) viric@2: { viric@2: base = realloc(base, STEP); viric@2: sysallocated += STEP; viric@2: } viric@2: else viric@2: { viric@2: base = realloc(base, newsize); viric@2: sysallocated += newsize; viric@2: } viric@2: } viric@2: viric@5: outptr = base + old_given; viric@5: viric@2: return outptr; viric@2: }