[Ecm-commits] r2574 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Mon Feb 2 07:41:14 CET 2015


Author: zimmerma
Date: 2015-02-02 07:41:14 +0100 (Mon, 02 Feb 2015)
New Revision: 2574

Modified:
   trunk/candi.c
   trunk/eval.c
Log:
use ASSERT_ALWAYS for checking result of malloc()


Modified: trunk/candi.c
===================================================================
--- trunk/candi.c	2015-02-01 06:36:26 UTC (rev 2573)
+++ trunk/candi.c	2015-02-02 06:41:14 UTC (rev 2574)
@@ -100,11 +100,7 @@
     {
       n->nexprlen = strlen (cpExpr);
       n->cpExpr = (char *) malloc (n->nexprlen + 1);
-      if (n->cpExpr == NULL)
-        {
-          fprintf (stderr, "Error: not enough memory\n");
-          exit (EXIT_FAILURE);
-        }
+      ASSERT_ALWAYS (n->cpExpr != NULL);
       strcpy (n->cpExpr, cpExpr);
     }
   mpz_set (n->n, c);
@@ -165,11 +161,7 @@
       /* If there is an expression, then lets preserve it */
       cp1 = mpz_get_str (NULL, 10, f);
       cp = (char *) malloc(n->nexprlen+1 + 3 + strlen(cp1));  /* +1 for null, +3 for ()/ */
-      if (cp == NULL)
-        {
-          fprintf (stderr, "Error: not enough memory\n");
-          exit (EXIT_FAILURE);
-        }
+      ASSERT_ALWAYS (cp != NULL);
       sprintf (cp, "(%s)/%s", n->cpExpr, cp1);
       free(n->cpExpr);
       n->cpExpr = cp;
@@ -227,11 +219,7 @@
   cp = go->cpOrigExpr;
   len = NumNs * mpz_sizeinbase (n->n, 10) + strlen (cp) + 100;
   numbuf = (char *) malloc(len);
-  if (numbuf == NULL)
-    {
-      fprintf (stderr, "Error: not enough memory\n");
-      exit (EXIT_FAILURE);
-    }
+  ASSERT_ALWAYS (numbuf != NULL);
   cpo = numbuf;
   while (*cp)
     {

Modified: trunk/eval.c
===================================================================
--- trunk/eval.c	2015-02-01 06:36:26 UTC (rev 2573)
+++ trunk/eval.c	2015-02-02 06:41:14 UTC (rev 2574)
@@ -70,11 +70,11 @@
 #endif
 #endif
 
-/**************************************/
-/* Main expression evalation function */
-/* This is the function that the app  */
-/* calls to read the expression line  */
-/**************************************/
+/***************************************/
+/* Main expression evaluation function */
+/* This is the function that the app   */
+/* calls to read the expression line   */
+/***************************************/
 int eval (mpcandi_t *n, FILE *fd, int primetest)
 {
   int ret;



More information about the Ecm-commits mailing list