From: Bart Van Assche Date: Wed, 10 Jun 2009 17:51:52 +0000 (+0000) Subject: Added test code for realloc(). X-Git-Tag: svn/VALGRIND_3_5_0~505 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31fd94279e40d8b703afd525e9331b8df7e2e19b;p=thirdparty%2Fvalgrind.git Added test code for realloc(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10292 --- diff --git a/drd/tests/memory_allocation.c b/drd/tests/memory_allocation.c index ddb0b325d2..4af3c4e767 100644 --- a/drd/tests/memory_allocation.c +++ b/drd/tests/memory_allocation.c @@ -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 #include int main() { int i; + void* p; + for (i = 0; i < 100000; i++) - { free(malloc(40960)); + + for (i = 0; i < 100000; i++) + { + p = realloc(NULL, 40960); + p = realloc(p, 50000); + p = realloc(p, 40000); + p = realloc(p, 0); + assert(! p); } + return 0; }