]> andersk Git - splint.git/blobdiff - src/general.c
Fixed bug in makefile causing unnecessary remaking of cgrammar.c.
[splint.git] / src / general.c
index cc6cb95dd3d0b9db17a8174d8c3f2cb966d2b5f6..b4bbca91e6f51d6e53518d20d3365cda919b80ef 100644 (file)
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on splint: splint@cs.virginia.edu
-** To report a bug: splint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
 ** For more information: http://www.splint.org
 */
 /*
@@ -86,6 +86,7 @@ static long unsigned size_toLongUnsigned (size_t x)
 }
 
 /*@out@*/ void *dimalloc (size_t size, const char *name, int line)
+     /*@ensures maxSet(result) == (size - 1); @*/ 
 {
   /*
   static void *lastaddr = 0;
@@ -112,8 +113,15 @@ static long unsigned size_toLongUnsigned (size_t x)
     {
       if (size == 0)
        {
-         llbug (message ("Zero allocation at %q.",
-                         fileloc_unparseRaw (cstring_fromChars (name), line)));
+         llcontbug (message ("Zero allocation at %q.",
+                             fileloc_unparseRaw (cstring_fromChars (name), line)));
+         
+         /* 
+         ** evans 2002-03-01
+         ** Return some allocated storage...hope we get lucky.
+         */
+
+         return dimalloc (16, name, line);
        }
       else
        {
@@ -179,21 +187,18 @@ void *direalloc (/*@out@*/ /*@null@*/ void *x, size_t size,
 
 /*@=mustdefine@*/
 
-# ifndef NOLCL
 char *FormatInt (int i)
 {
   char temp[255]; /* assume the integer has at most 254 digits */
   char *outs;
-
-  sprintf (temp, "%i", i);
+  int sres = snprintf (temp, 255, "%i", i);
+  check (sres >= 0 && sres <= 255);
   outs = (char *) dmalloc (sizeof (*outs) * (1 + strlen (temp)));
   strcpy (outs, temp);
 
   return (outs);
 }
-# endif
 
-# ifndef NOLCL
 bool firstWord (char *s, char *w)
 {
   llassert (s != NULL);
@@ -206,7 +211,6 @@ bool firstWord (char *s, char *w)
     }
   return TRUE;
 }
-# endif
 
 void mstring_markFree (char *s)
 {
@@ -306,7 +310,7 @@ mstring_append (/*@only@*/ char *s1, char c)
 }
 
 extern 
-char *mstring_copy (char *s1)
+char *mstring_copy (char *s1) /*@ensures maxRead(result) == maxRead(s1) /\  maxSet(result) == maxSet(s1) @*/
 {
   if (s1 == NULL)
     {
@@ -334,7 +338,7 @@ char *mstring_safePrint (char *s)
 }
 
 extern
-char *mstring_create (int n)
+char *mstring_create (size_t n)
 {
   char *s;
 
@@ -354,7 +358,7 @@ fputline (FILE *out, char *s)
   check (fputc ('\n', out) == (int) '\n');
 }
 
-unsigned int int_toNonNegative (int x)
+unsigned int int_toNonNegative (int x) /*@*/
 {
   llassert (x >= 0);
   return (unsigned) x;
@@ -382,7 +386,7 @@ longUnsigned_fromInt (int x)
   return (long unsigned) x;
 }
 
-size_t size_fromInt (int x)
+size_t size_fromInt (int x) /*@ensures result==x@*/
 {
   size_t res = (size_t) x;
 
This page took 0.06985 seconds and 4 git commands to generate.