diff --git a/test/Makefile b/test/Makefile index 56b6201..dbcaa09 100644 --- a/test/Makefile +++ b/test/Makefile @@ -9,7 +9,8 @@ CPPFLAGS += \ EXECUTABLES := \ offset \ - mallinfo + mallinfo \ + large_array_growth all: $(EXECUTABLES) diff --git a/test/large_array_growth.c b/test/large_array_growth.c new file mode 100644 index 0000000..dfa61a0 --- /dev/null +++ b/test/large_array_growth.c @@ -0,0 +1,17 @@ +#include +#include + +__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; + } +}