svn commit: trunk/uClibc/test/malloc
vapier at uclibc.org
vapier at uclibc.org
Wed Apr 11 22:53:54 UTC 2007
Author: vapier
Date: 2007-04-11 15:53:54 -0700 (Wed, 11 Apr 2007)
New Revision: 18407
Log:
test case to make sure realloc() can shrink buffers properly
Added:
trunk/uClibc/test/malloc/realloc-can-shrink.c
Changeset:
Added: trunk/uClibc/test/malloc/realloc-can-shrink.c
===================================================================
--- trunk/uClibc/test/malloc/realloc-can-shrink.c (rev 0)
+++ trunk/uClibc/test/malloc/realloc-can-shrink.c 2007-04-11 22:53:54 UTC (rev 18407)
@@ -0,0 +1,17 @@
+/* make sure that realloc() can properly shrink buffers */
+
+#include <stdlib.h>
+
+#define LARGE_BUFFER (1 << 20) /* idea is to span a lot of pages */
+
+int main()
+{
+ int count = 20;
+ char *ptr = NULL;
+ while (count--) {
+ ptr = realloc(ptr, LARGE_BUFFER);
+ ptr = realloc(ptr, 1);
+ }
+ free(ptr);
+ return 0;
+}
More information about the uClibc-cvs
mailing list