OSDN Git Service

Fix tests to work if MALLOC_GLIBC_COMPAT is enabled.
author"Steven J. Hill" <sjhill@realitydiluted.com>
Fri, 17 Mar 2006 02:43:51 +0000 (02:43 -0000)
committer"Steven J. Hill" <sjhill@realitydiluted.com>
Fri, 17 Mar 2006 02:43:51 +0000 (02:43 -0000)
test/malloc/malloc.c
test/malloc/tst-malloc.c
test/malloc/tst-mcheck.c

index d638568..b35e329 100644 (file)
@@ -70,7 +70,11 @@ 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 468e1d4..95d8a6c 100644 (file)
@@ -54,9 +54,16 @@ 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)
@@ -66,8 +73,16 @@ 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 af72c04..7476538 100644 (file)
@@ -50,7 +50,11 @@ 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);
@@ -62,7 +66,11 @@ 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);