add large array growth test

pull/87/head
Daniel Micay 2019-04-30 16:47:06 -04:00
parent ae4142c2d1
commit 2ae0ed4674
2 changed files with 19 additions and 1 deletions

View File

@ -9,7 +9,8 @@ CPPFLAGS += \
EXECUTABLES := \
offset \
mallinfo
mallinfo \
large_array_growth
all: $(EXECUTABLES)

17
test/large_array_growth.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdlib.h>
#include <string.h>
__attribute__((optimize(0)))
int main(void) {
void *p = NULL;
size_t size = 256 * 1024;
for (unsigned i = 0; i < 20; i++) {
p = realloc(p, size);
if (!p) {
return 1;
}
memset(p, 'a', size);
size = size * 3 / 2;
}
}