]> andersk Git - splint.git/blobdiff - src/constraintList.c
Changes to fix malloc size problem.
[splint.git] / src / constraintList.c
index ba719e9e992cba8fc59c97fa5b050792ee720945..c834ec65f6d3e1a284a87a7b949093e309050bde 100644 (file)
@@ -92,11 +92,14 @@ constraintList_add (/*@returned@*/ constraintList s, /*@only@*/ constraint el)
 
   /*drl7x */
 
-  if (constraintList_resolve (el, s) )
+  if (constraintList_resolve (el, s))
     {
+      DPRINTF (("Resolved constraint: %s", constraint_unparse (el)));
       constraint_free (el);
       return s;
     }
+
+  DPRINTF (("Adding constraint: %s", constraint_unparse (el)));
   
   if (s->nspace <= 0)
     constraintList_grow (s);
@@ -126,15 +129,15 @@ static void constraintList_freeShallow (/*@only@*/ constraintList c)
 
 /*@only@*/ constraintList constraintList_addList (/*@only@*/ /*@returned@*/ constraintList s, /*@observer@*/ /*@temp@*/ constraintList newList)
 {
-  llassert(constraintList_isDefined(s) );
-  llassert(constraintList_isDefined(newList) );
+  llassert(constraintList_isDefined (s));
+  llassert(constraintList_isDefined (newList));
 
   if (newList == constraintList_undefined)
     return s;
   
   constraintList_elements (newList, elem)
     {
-    s = constraintList_add (s, constraint_copy(elem) );
+      s = constraintList_add (s, constraint_copy(elem));
     }
   end_constraintList_elements;
 
@@ -143,32 +146,30 @@ static void constraintList_freeShallow (/*@only@*/ constraintList c)
 
 constraintList constraintList_addListFree (/*@returned@*/ constraintList s, /*@only@*/ constraintList newList)
 {
-  llassert(constraintList_isDefined(s) );
-  llassert(constraintList_isDefined(newList) );
-
-  if (constraintList_isUndefined(newList) )
+  if (constraintList_isUndefined (newList))
     return s;
+
+  llassert (constraintList_isDefined (s));
+  llassert (constraintList_isDefined (newList));
   
   constraintList_elements_private_only(newList, elem)
     {
-    s = constraintList_add (s, elem);
-    }
-  end_constraintList_elements_private_only
-
-    constraintList_freeShallow(newList);
-    return s;
+      s = constraintList_add (s, elem);
+    } end_constraintList_elements_private_only;
+  
+  constraintList_freeShallow (newList);
+  return s;
 }
 
-
 constraintList constraintList_removeSurpressed (/*@only@*/ constraintList s)
 {
   constraintList ret;
   fileloc loc;
-  llassert(constraintList_isDefined(s) );
 
+  llassert (constraintList_isDefined (s));
   ret = constraintList_makeNew();
   
-  constraintList_elements_private_only(s, elem)
+  constraintList_elements_private_only (s, elem)
     {
       loc = constraint_getFileloc(elem);
 
@@ -176,14 +177,12 @@ constraintList constraintList_removeSurpressed (/*@only@*/ constraintList s)
        {
          ret = constraintList_add (ret, elem);
        }
-      
       else if (context_suppressFlagMsg(FLG_BOUNDSWRITE, loc) )
        {
          DPRINTF ((message ("constraintList_removeSurpressed getting rid of surpressed constraint %q", 
                             constraint_unparse(elem))));
          constraint_free(elem);
        }
-      
       else if (!constraint_hasMaxSet(elem) && context_suppressFlagMsg(FLG_BOUNDSREAD, loc))
        {
          DPRINTF ((message("constraintList_removeSurpressed getting rid of surpressed constraint %q", 
@@ -195,11 +194,9 @@ constraintList constraintList_removeSurpressed (/*@only@*/ constraintList s)
          ret = constraintList_add (ret, elem);
        } 
       fileloc_free(loc);
-    } 
-  end_constraintList_elements_private_only;
+    } end_constraintList_elements_private_only;
 
   constraintList_freeShallow(s);
-  
   return ret;
 }
 
@@ -638,6 +635,38 @@ void constraintList_dump (/*@observer@*/ constraintList c,  FILE *f)
   end_constraintList_elements; ;
 }
 
+//! don't use this!
+void constraintList_castConstraints (constraintList c, ctype tfrom, ctype tto)
+{
+  if (TRUE) /* flag to allow casting */ 
+    {
+      int fsize = ctype_getSize (tfrom);
+      int tsize = ctype_getSize (tto);
+
+      DPRINTF (("Sizes: [%s] [%s] %d / %d", ctype_unparse (tfrom),
+               ctype_unparse (tto), fsize, tsize));
+
+      if (fsize == tsize) 
+       {
+         return; /* Sizes match, no change to constraints */
+       }
+      else 
+       {
+         float scale = fsize / tsize;
+         
+         DPRINTF (("Scaling constraints by: %f", scale));
+
+         constraintList_elements (c, el)
+           {
+             DPRINTF (("Scale: %s", constraint_unparse (el)));
+             // constraint_scaleSize (el, scale);
+             DPRINTF (("   ==> %s", constraint_unparse (el)));
+           }
+         end_constraintList_elements; 
+       }
+    }
+}
+
 
 constraintList constraintList_sort (/*@returned@*/ constraintList ret)
 {
@@ -646,6 +675,7 @@ constraintList constraintList_sort (/*@returned@*/ constraintList ret)
       llassert(FALSE);
       return ret;
     }
+
   qsort (ret->elements, (size_t) ret->nelements,
         (sizeof (*ret->elements)), 
         (int (*)(const void *, const void *)) constraint_compare);
This page took 0.04817 seconds and 4 git commands to generate.