Eric Norum's suggeston to install doc to standard place
[fw/sdcc] / sim / ucsim / pobj.cc
index ae9e850bae0a55eca7825e6452db2c86481abba8..d2e164c14dd97de0c6320ba5af36eab377ad1f20 100644 (file)
@@ -55,7 +55,6 @@ cl_base::cl_base(void) {}
 
 cl_base::~cl_base(void) {}
 
-
 int cl_base::init(void) {return(0);}
 
 
@@ -87,7 +86,8 @@ cl_list::cl_list(t_index alimit, t_index adelta):
 
 cl_list::~cl_list(void)
 {
-  delete Items;
+  //delete Items;
+  free(Items);
 }
 
 
@@ -136,7 +136,10 @@ cl_list::disconn_at(t_index index)
 void
 cl_list::disconn(void *item)
 {
-  disconn_at(index_of(item));
+  t_index i;
+
+  if (index_of(item, &i))
+    disconn_at(i);
 }
 
 
@@ -164,6 +167,19 @@ cl_list::free_at(t_index index)
   free_item(Item);
 }
 
+void
+cl_list::free_all(void)
+{
+  t_index i;
+
+  if (count)
+    {
+      for (i= count-1; i; i--)
+       free_at(i);
+      free_at(0);
+    }
+}
+
 
 /*
  * Inserting a new item to the exact position
@@ -248,7 +264,7 @@ cl_list::for_each(iterator_func action, void *arg)
 void
 cl_list::free_item(void *item)
 {
-  delete item;
+  delete (class cl_base*)item;
 }
 
 
@@ -297,6 +313,19 @@ cl_list::index_of(void *item)
   return(0);    /* Needed by Sun! */
 }
 
+bool
+cl_list::index_of(void *item, t_index *idx)
+{
+  for (t_index i= 0; i < count; i++)
+    if (item == Items[i])
+      {
+       if (idx)
+         *idx= i;
+       return(DD_TRUE);
+      }
+  return(DD_FALSE);
+}
+
 
 /* 
  * Inserting a new item to the collection.
@@ -377,13 +406,14 @@ cl_list::set_limit(t_index alimit)
        AItems= 0;
       else
        {
-         AItems = new void *[alimit];
-         //i= ALimit*(sizeof(void *));
-         //AItems= (void **)malloc(i);
+         //AItems = new void *[alimit];
+         int i= alimit*(sizeof(void *));
+         AItems= (void **)malloc(i);
          if (count)
            memcpy(AItems, Items, count*sizeof(void *));
        }
-      delete Items;
+      //delete Items;
+      free(Items);
       Items= AItems;
       Limit= alimit;
     }
@@ -404,7 +434,7 @@ cl_list::set_limit(t_index alimit)
 cl_sorted_list::cl_sorted_list(t_index alimit, t_index adelta):
   cl_list(alimit, adelta)
 {
-  Duplicates= FALSE;
+  Duplicates= DD_FALSE;
 }
 
 
@@ -474,7 +504,7 @@ cl_sorted_list::search(void *key, t_index &index)
 {
   t_index l  = 0;
   t_index h  = count - 1;
-  bool   res= FALSE;
+  bool    res= DD_FALSE;
   
   while (l <= h)
     {
@@ -486,7 +516,7 @@ cl_sorted_list::search(void *key, t_index &index)
          h= i - 1;
          if (c == 0)
            {
-             res= TRUE;
+             res= DD_TRUE;
              if (!Duplicates)
                l= i;
            }
@@ -511,7 +541,7 @@ cl_sorted_list::search(void *key, t_index &index)
 cl_strings::cl_strings(t_index alimit, t_index adelta):
   cl_sorted_list(alimit, adelta)
 {
-  Duplicates= TRUE;
+  Duplicates= DD_TRUE;
 }
 
 
@@ -536,7 +566,7 @@ cl_strings::compare(void *key1, void *key2)
 void
 cl_strings::free_item(void* item)
 {
-  delete item;
+  delete (class cl_base*)item;
 }
 
 
@@ -578,7 +608,7 @@ bool
 cl_ustrings::search(void *key, t_index& index)
 {
   t_index i    = 0;
-  bool    found= FALSE;
+  bool    found= DD_FALSE;
   void    *Actual;
 
   if ((count) && key)