Mark 'atexit' obsolete.
[gnulib.git] / tests / test-strstr.c
index a4cc0fc..8a05e88 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <string.h>
 
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -29,6 +30,7 @@
       if (!(expr))                                                          \
        {                                                                    \
          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+         fflush (stderr);                                                   \
          abort ();                                                          \
        }                                                                    \
     }                                                                       \
@@ -42,7 +44,8 @@ main (int argc, char *argv[])
      caused by SIGALRM.  All known platforms that lack alarm also have
      a quadratic strstr, and the replacement strstr is known to not
      take too long.  */
-  alarm (10);
+  signal (SIGALRM, SIG_DFL);
+  alarm (50);
 #endif
 
   {
@@ -142,10 +145,8 @@ main (int argc, char *argv[])
        result = strstr (haystack, needle);
        ASSERT (result == haystack + m);
       }
-    if (needle != NULL)
-      free (needle);
-    if (haystack != NULL)
-      free (haystack);
+    free (needle);
+    free (haystack);
   }
 
   /* Sublinear speed is only possible in memmem; strstr must examine