OSDN Git Service

Fix 'realloc' and revert previous changes to tests. malloc tests all pass regardless...
author"Steven J. Hill" <sjhill@realitydiluted.com>
Fri, 17 Mar 2006 03:00:05 +0000 (03:00 -0000)
committer"Steven J. Hill" <sjhill@realitydiluted.com>
Fri, 17 Mar 2006 03:00:05 +0000 (03:00 -0000)
libc/stdlib/malloc-standard/realloc.c
test/malloc/malloc.c
test/malloc/tst-malloc.c
test/malloc/tst-mcheck.c

index ae2d33b..f25d6d9 100644 (file)
@@ -52,7 +52,7 @@ void* realloc(void* oldmem, size_t bytes)
        return malloc(bytes);
     if (! bytes) {
        free (oldmem);
-       return malloc(bytes);
+       return NULL;
     }
 
     LOCK;
index b35e329..d638568 100644 (file)
@@ -70,11 +70,7 @@ int test2(void)
        
        ptr = malloc(100);
        ptr = realloc(ptr, 0);
-#ifdef __MALLOC_GLIBC_COMPAT__
-       if (!ptr) {
-#else
        if (ptr) {
-#endif
                printf("realloc(,0) failed\n");
                ++ret;
                free(ptr);
index 95d8a6c..468e1d4 100644 (file)
@@ -54,16 +54,9 @@ main (void)
 
   /* realloc (p, 0) == free (p).  */
   p = realloc (p, 0);
-#ifdef __MALLOC_GLIBC_COMPAT__
-  if (!p)
-#else
   if (p != NULL)
-#endif
     merror ("realloc (p, 0) failed.");
 
-#ifdef __MALLOC_GLIBC_COMPAT__
-  free (p);
-#endif
   p = malloc (0);
 #if !defined(__UCLIBC__) || defined(__MALLOC_GLIBC_COMPAT__)
   if (p == NULL)
@@ -73,16 +66,8 @@ main (void)
     merror ("malloc (0) failed.");
 
   p = realloc (p, 0);
-#ifdef __MALLOC_GLIBC_COMPAT__
-  if (!p)
-#else
   if (p != NULL)
-#endif
     merror ("realloc (p, 0) failed.");
 
-#ifdef __MALLOC_GLIBC_COMPAT__
-  free (p);
-#endif
-
   return errors != 0;
 }
index 7476538..af72c04 100644 (file)
@@ -50,11 +50,7 @@ main (void)
     merror ("malloc (10) failed.");
 
   p = realloc (p, 0);
-#ifdef __MALLOC_GLIBC_COMPAT__
-  if (!p)
-#else
   if (p != NULL)
-#endif
     merror ("realloc (p, 0) failed.");
 
   p = malloc (0);
@@ -66,11 +62,7 @@ main (void)
     merror ("malloc (0) failed.");
 
   p = realloc (p, 0);
-#ifdef __MALLOC_GLIBC_COMPAT__
-  if (!p)
-#else
   if (p != NULL)
-#endif
     merror ("realloc (p, 0) failed.");
 
   q = malloc (256);