|
From: <sv...@va...> - 2009-06-10 17:51:59
|
Author: bart Date: 2009-06-10 18:51:52 +0100 (Wed, 10 Jun 2009) New Revision: 10292 Log: Added test code for realloc(). Modified: trunk/drd/tests/memory_allocation.c Modified: trunk/drd/tests/memory_allocation.c =================================================================== --- trunk/drd/tests/memory_allocation.c 2009-06-10 06:13:34 UTC (rev 10291) +++ trunk/drd/tests/memory_allocation.c 2009-06-10 17:51:52 UTC (rev 10292) @@ -1,15 +1,28 @@ -/* Repeatedly allocate and free memory. Tests whether drd */ -/* really frees memory allocated by a client. See also */ -/* http://bugs.kde.org/show_bug.cgi?id=161036 */ +/** + * @brief Repeatedly allocate and free memory. Tests whether drd really frees + * memory allocated by a client. See also + * http://bugs.kde.org/show_bug.cgi?id=161036. + */ +#include <assert.h> #include <stdlib.h> int main() { int i; + void* p; + for (i = 0; i < 100000; i++) + free(malloc(40960)); + + for (i = 0; i < 100000; i++) { - free(malloc(40960)); + p = realloc(NULL, 40960); + p = realloc(p, 50000); + p = realloc(p, 40000); + p = realloc(p, 0); + assert(! p); } + return 0; } |