* Initializing the object
*/
-cl_base::cl_base(void) {}
+cl_base::cl_base(void)
+{
+ name= 0;
+}
/*
* Destructing the object: calling hte virtual Done method
*/
-cl_base::~cl_base(void) {}
-
+cl_base::~cl_base(void)
+{
+ if (name)
+ free(name);
+}
int cl_base::init(void) {return(0);}
+char *
+cl_base::get_name(char *def)
+{
+ if (!name)
+ return(def);
+ return(name);
+}
+
+char *
+cl_base::set_name(char *new_name)
+{
+ if (name)
+ free(name);
+ if (!new_name)
+ name= 0;
+ else if (*new_name)
+ name= strdup(new_name);
+ else
+ name= strdup("");
+ return(name);
+}
+
/* *
==========================================================================*
cl_list::~cl_list(void)
{
- delete Items;
+ //delete Items;
+ free(Items);
}
void
cl_list::disconn(void *item)
{
- disconn_at(index_of(item));
+ t_index i;
+
+ if (index_of(item, &i))
+ disconn_at(i);
}
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
void
cl_list::free_item(void *item)
{
- delete item;
+ delete (class cl_base*)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.
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;
}
cl_sorted_list::cl_sorted_list(t_index alimit, t_index adelta):
cl_list(alimit, adelta)
{
- Duplicates= FALSE;
+ Duplicates= DD_FALSE;
}
{
t_index l = 0;
t_index h = count - 1;
- bool res= FALSE;
+ bool res= DD_FALSE;
while (l <= h)
{
h= i - 1;
if (c == 0)
{
- res= TRUE;
+ res= DD_TRUE;
if (!Duplicates)
l= i;
}
cl_strings::cl_strings(t_index alimit, t_index adelta):
cl_sorted_list(alimit, adelta)
{
- Duplicates= TRUE;
+ Duplicates= DD_TRUE;
}
void
cl_strings::free_item(void* item)
{
- delete item;
+ delete (class cl_base*)item;
}
cl_ustrings::search(void *key, t_index& index)
{
t_index i = 0;
- bool found= FALSE;
+ bool found= DD_FALSE;
void *Actual;
if ((count) && key)