gEDA-dev: Broken slotting
Steve Meier
smeier at alchemyresearch.com
Tue Sep 11 13:36:33 EDT 2007
Peter,
Thanks for your input.
In general I use for each data structure a common set of methods.
These being struct_new, struct_init, struct_free, struct_duplicate,
struct_print
I also have started adding struct_get_reference to the above common api.
for graphical structures ones that get displayed or printed or
written/read from a file, I also use (or try to use) a common set of
additional methods.
struct_draw, struct_read, struct_write
Reading your critisim I see some very usefull input.
1) Collect all the related methods together in the header file. Thus all
of those "Again, special case slot stuff." at least should be clearly
grouped so that we can see which ones are usefull and which are just
trivial dupplication.
2) Come to an agreement as too what should be the base set of methods
and base set off additional graphic methods.
3) Have a clear understanding of how the methods support usefull work
needed to be done for/by other structures.
4) improve the comments for each method where they are unclear
for discussions sake,
You have suggested combining the struct_new and struct_init into a
single method.
struct_new always allocates memory for the structure and initialzes the
structure elements to known values.
struct_init then adds whatever values I think that a new instance of a
structure needs, however sometimes I want the structure to contain some
of the same pointers to other structures that another instance of that
structure has. But, now I am scratching my head looking for a cse where
I wouldn't have been happy with the two methods combined.
struct_free is responsible for first are there any other references to
this structure if so then just decrement the reference count, if not
then aske all other structures that are elements of this structure to
free themselves and after that is done then this structure frees its
memory.
Thanks again,
Steve Meier
More information about the geda-dev
mailing list