From 7988979a722b4cdf287b2093956a76a3f19b9897 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Mon, 24 Oct 2016 20:22:12 +0200 Subject: add uClibc-ng test directory --- test/malloc/realloc-can-shrink.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/malloc/realloc-can-shrink.c (limited to 'test/malloc/realloc-can-shrink.c') diff --git a/test/malloc/realloc-can-shrink.c b/test/malloc/realloc-can-shrink.c new file mode 100644 index 0000000..33249db --- /dev/null +++ b/test/malloc/realloc-can-shrink.c @@ -0,0 +1,17 @@ +/* make sure that realloc() can properly shrink buffers */ + +#include + +#define LARGE_BUFFER (1 << 20) /* idea is to span a lot of pages */ + +int main(int argc, char *argv[]) +{ + int count = 20; + char *ptr = NULL; + while (count--) { + ptr = realloc(ptr, LARGE_BUFFER); + ptr = realloc(ptr, 1); + } + free(ptr); + return 0; +} -- cgit v1.2.3