[Ecm-commits] r2608 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Fri Feb 13 07:35:19 CET 2015


Author: zimmerma
Date: 2015-02-13 07:35:19 +0100 (Fri, 13 Feb 2015)
New Revision: 2608

Modified:
   trunk/eval.c
Log:
improve coverage


Modified: trunk/eval.c
===================================================================
--- trunk/eval.c	2015-02-12 22:55:36 UTC (rev 2607)
+++ trunk/eval.c	2015-02-13 06:35:19 UTC (rev 2608)
@@ -82,11 +82,7 @@
   int c;
   char *expr = (char *) malloc (nMaxSize + 1);
 
-  if (expr == NULL)
-    {
-      fprintf (stderr, "Error: not enough memory\n");
-      exit (EXIT_FAILURE);
-    }
+  ASSERT_ALWAYS (expr != NULL);
 /* Lines ending in '\\' are "joined" as a single longer line */
 JoinLinesLoop:;
   c = fgetc (fd);
@@ -124,12 +120,7 @@
 	char *cp;
 	nMaxSize += nMaxSize / 2;
 	cp = (char *) realloc (expr, nMaxSize + 1);
-	if (!cp)
-	{
-	  free (expr);
-	  fprintf (stderr, "Severe warning!, out of core memory reading number!\n");
-	  exit (EXIT_FAILURE);
-	}
+        ASSERT_ALWAYS (cp != NULL);
 	expr = cp;
       }
       c = fgetc (fd);
@@ -173,11 +164,7 @@
   char *c;
   char *expr = (char *) malloc(nMaxSize+1);
 
-  if (expr == NULL)
-    {
-      fprintf (stderr, "Error: not enough memory\n");
-      exit (EXIT_FAILURE);
-    }
+  ASSERT_ALWAYS (expr != NULL);
 /* Lines ending in '\\' are "joined" as a single longer line */
   c = cp;
 JoinLinesLoop:;
@@ -198,14 +185,9 @@
       if (nCurSize == nMaxSize)
       {
 	char *cp;
-	nMaxSize += 5000;
+	nMaxSize += nMaxSize / 2;
 	cp = (char *) realloc (expr, nMaxSize + 1);
-	if (!cp)
-	{
-	  free(expr);
-	  fprintf(stderr, "Severe warning!, out of core memory reading number!\n");
-	  exit (EXIT_FAILURE);
-	}
+        ASSERT_ALWAYS (cp != NULL);
 	expr = cp;
       }
       ++c;



More information about the Ecm-commits mailing list