ChangeLog Fix realloc() to match the documented behaviour. Add a few simple tests for it. Index: dlls/msvcrt/heap.c =================================================================== RCS file: /var/cvs/wine/dlls/msvcrt/heap.c,v retrieving revision 1.13 diff -u -r1.13 heap.c --- dlls/msvcrt/heap.c 17 Sep 2002 18:32:53 -0000 1.13 +++ dlls/msvcrt/heap.c 20 Nov 2003 06:29:28 -0000 @@ -281,5 +281,8 @@ */ void* MSVCRT_realloc(void* ptr, MSVCRT_size_t size) { - return HeapReAlloc(GetProcessHeap(), 0, ptr, size); + if (!ptr) return MSVCRT_malloc(size); + if (size) return HeapReAlloc(GetProcessHeap(), 0, ptr, size); + MSVCRT_free(ptr); + return NULL; } Index: dlls/msvcrt/tests/Makefile.in =================================================================== RCS file: /var/cvs/wine/dlls/msvcrt/tests/Makefile.in,v retrieving revision 1.3 diff -u -r1.3 Makefile.in --- dlls/msvcrt/tests/Makefile.in 24 Sep 2003 18:49:45 -0000 1.3 +++ dlls/msvcrt/tests/Makefile.in 20 Nov 2003 19:27:37 -0000 @@ -9,6 +9,7 @@ CTESTS = \ cpp.c \ file.c \ + mem.c \ scanf.c @MAKE_TEST_RULES@ --- /dev/null 2003-01-30 05:24:37.000000000 -0500 +++ dlls/msvcrt/tests/mem.c 2003-11-20 14:32:32.000000000 -0500 @@ -0,0 +1,41 @@ +/* + * Unit test suite for memory functions + * + * Copyright 2003 Dimitrie O. Paun + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "wine/test.h" +#include <stdlib.h> + +static void test_realloc( void ) +{ + void *mem = NULL; + + mem = realloc(mem, 10); + ok(mem != NULL, "memory not allocated"); + + mem = realloc(mem, 20); + ok(mem != NULL, "memory not reallocated"); + + mem = realloc(mem, 0); + ok(mem == NULL, "memory nto freed"); +} + +START_TEST(mem) +{ + test_realloc(); +} -- Dimi.