Re: [Libclc-developers] cvs/work_in_progress/stl/clc_list.c
Status: Planning
Brought to you by:
augestad
From: regis <re...@in...> - 2003-04-05 19:49:45
|
regis wrote: > > I found the code below in clc_list.c the cvs repository: > > <code> > > struct clc_list_tag { > struct clc_list_tag *next, *prev; > void* data; > }; > > clc_list clc_list_new(void) > { > clc_list lst; > > lst = calloc(1, sizeof *lst); > return lst; > } > > </code> [...] Just before leaving my office, a general remark about the design of the list. confusing a list with a list-node and defining a list as a pointer to a leading dummy list-node is dangerous and prevents any evolution: that means that a list has no other knowledge than a list-node. For example, what happens the list has later to maintain its cardinality so that it can be queried in constant time instead of linear time? We can't do it. Generally, it is a bad idea to use the same structures for containers and their container-cells, even if they are mathematically defined as recursive objects For the same reason, a tree should not be confused with its root or a dummy node pointing to its root. clc_list and clc_listnode should be distinct structs. -- Regis |