]> andersk Git - splint.git/blobdiff - src/general.c
Pushed back constraintResolve.c to the previous version.
[splint.git] / src / general.c
index dd72788fd32809088471c8aafd635c546e8682b4..972420079cde04b7be3ae3f554c2fbc149469108 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -113,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
        {
@@ -180,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);
@@ -207,7 +211,6 @@ bool firstWord (char *s, char *w)
     }
   return TRUE;
 }
-# endif
 
 void mstring_markFree (char *s)
 {
@@ -335,7 +338,7 @@ char *mstring_safePrint (char *s)
 }
 
 extern
-char *mstring_create (int n)
+char *mstring_create (size_t n)
 {
   char *s;
 
@@ -391,6 +394,22 @@ size_t size_fromInt (int x) /*@ensures result==x@*/
   return res;
 }
 
+size_t size_fromLong (long x) /*@ensures result==x@*/
+{
+  size_t res = (size_t) x;
+
+  llassert ((long) res == x);
+  return res;
+}
+
+size_t size_fromLongUnsigned (unsigned long x) /*@ensures result==x@*/
+{
+  size_t res = (size_t) x;
+
+  llassert ((unsigned long) res == x);
+  return res;
+}
+
 int size_toInt (size_t x)
 {
   int res = (int) x;
This page took 0.401258 seconds and 4 git commands to generate.