From 2ae0ed4674bae395405233c31c748f67173610ac Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 30 Apr 2019 16:47:06 -0400 Subject: [PATCH] add large array growth test --- test/Makefile | 3 ++- test/large_array_growth.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/large_array_growth.c 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; + } +}