Re: [Libclc-developers] An alternative clc_list approach + an iterator.
Status: Planning
Brought to you by:
augestad
|
From: <bo...@me...> - 2003-03-26 16:11:57
|
Hallvard B Furuseth wrote: > Bjørn Augestad writes: > >>Hallvard B Furuseth wrote: >> >>>clc_stl.h says: >>> >>> typedef struct clc_list_tag* clc_list; >>> typedef struct clc_iterator_tag* clc_iterator; >>> >>>I think typedefs to pointers like this is a bad idea. >>>(...) I'd rather see >>> >>> typedef struct clc_list_tag clc_list; >>> typedef struct clc_iterator_tag clc_iterator; >>> >>>(...) >> >>Thanks for the feedback. The general concensus on c.l.c seems to be that >>it's OK to typedef the pointer if no struct members are available >>outside the implementation. > > > That's not what c.l.c said last time. They said one should normally not > typedef a struct at all, but it's OK if no struct members are available > outside the implementation. While typedefs to pointers are evil. See: > > http://groups.google.com/groups?selm=newscache%2405mrbh%24jt1%241%40tomato.pcug.org.au > http://groups.google.com/groups?selm=b553pt%245f8%241%40sunnews.cern.ch I must have misread those the last time, possibly mixing in memories from the clc_bitset discussion where this issue was discussed as well. Memory can be quite selective... Let's continue to disagree for a while, shall we? ;-) >>We can compromise by dropping the _tag suffix, >> typedef struct foo* foo; > > > Absolutely not! If we have a struct tag and a typedef with the same > name, they should be the same type. That was a joke. :-) >>Does the design easily create mem leaks? > > > Maybe. It would be safer with > struct clc_iterator iter; > clc_iterator_init(&iter, ...); > because then many iterators would not need to be freed at all. Can't do that with an ADT. It has to be allocated since it is an incomplete type. -- boa libclc home: http://libclc.sourceforge.net |