Index: trunk/src/libcschem/abstract.c =================================================================== --- trunk/src/libcschem/abstract.c (revision 829) +++ trunk/src/libcschem/abstract.c (revision 830) @@ -33,6 +33,44 @@ #include "abstract.h" #include "compat.h" +void csch_ahdr_uninit(csch_ahdr_t *hdr) +{ + csch_attrib_uninit(&hdr->attr); +} + +void csch_anet_free_fields(csch_anet_t *net) +{ + vtp0_uninit(&net->conns); + free(net->netname); + csch_ahdr_uninit(&net->hdr); +} + +void csch_aport_free_fields(csch_aport_t *port) +{ + free(port->name); + csch_ahdr_uninit(&port->hdr); +} + + +void csch_acomp_free_fields(csch_acomp_t *comp) +{ + htsp_entry_t *e; + + for(e = htsp_first(&comp->ports); e != NULL; e = htsp_next(&comp->ports, e)) { + csch_aport_free_fields(e->value); + free(e->value); e->value = NULL; + } + for(e = htsp_first(&comp->busports); e != NULL; e = htsp_next(&comp->busports, e)) { + abort(); + } + + htsp_uninit(&comp->ports); + htsp_uninit(&comp->busports); + free(comp->name); + csch_ahdr_uninit(&comp->hdr); +} + + void csch_abstract_init(csch_abstract_t *abs) { memset(abs, 0, sizeof(csch_abstract_t)); @@ -42,6 +80,27 @@ abs->next_aid = 1; } +void csch_abstract_uninit(csch_abstract_t *abs) +{ + htsp_entry_t *e; + + for(e = htsp_first(&abs->nets); e != NULL; e = htsp_next(&abs->nets, e)) { + csch_anet_free_fields(e->value); + free(e->value); e->value = NULL; + } + + for(e = htsp_first(&abs->comps); e != NULL; e = htsp_next(&abs->comps, e)) { + csch_acomp_free_fields(e->value); + free(e->value); e->value = NULL; + } + + htsp_uninit(&abs->nets); + htsp_uninit(&abs->comps); + htip_uninit(&abs->aid2obj); + memset(abs, 0, sizeof(csch_abstract_t)); +} + + /* Initialize an object by setting the common header fields; the only purpose of this function is to get compiler warnings at every caller when the header is extended (because the number of args would be extended here) */ Index: trunk/src/libcschem/abstract.h =================================================================== --- trunk/src/libcschem/abstract.h (revision 829) +++ trunk/src/libcschem/abstract.h (revision 830) @@ -125,6 +125,7 @@ /*** abs ***/ void csch_abstract_init(csch_abstract_t *abs); +void csch_abstract_uninit(csch_abstract_t *abs); void csch_abstract_dump(const csch_abstract_t *abs, FILE *f, const char *prefix); /*** net ***/