mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 00:56:15 +02:00
eeshow/lib-parse.c (lib_free): add cleanup of component data
This commit is contained in:
parent
c54bf3de06
commit
59b7946a5f
@ -268,3 +268,39 @@ void lib_init(struct lib *lib)
|
||||
lib->comps = NULL;
|
||||
lib->next_comp = &lib->comps;
|
||||
}
|
||||
|
||||
|
||||
static void free_objs(struct lib_obj *objs)
|
||||
{
|
||||
struct lib_obj *next;
|
||||
|
||||
while (objs) {
|
||||
next = objs->next;
|
||||
switch (objs->type) {
|
||||
case lib_obj_text:
|
||||
free((char *) objs->u.text.s);
|
||||
break;
|
||||
case lib_obj_pin:
|
||||
free((char *) objs->u.pin.name);
|
||||
free((char *) objs->u.pin.number);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
free(objs);
|
||||
objs = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lib_free(struct lib *lib)
|
||||
{
|
||||
struct comp *comp, *next;
|
||||
|
||||
for (comp = lib->comps; comp; comp = next) {
|
||||
next = comp->next;
|
||||
free((char *) comp->name);
|
||||
free_objs(comp->objs);
|
||||
free(comp);
|
||||
}
|
||||
}
|
||||
|
@ -121,5 +121,6 @@ void lib_render(const struct comp *comp, unsigned unit, const int m[6]);
|
||||
|
||||
void lib_parse(struct lib *lib, const char *name, const struct file *related);
|
||||
void lib_init(struct lib *lib);
|
||||
void lib_free(struct lib *lib);
|
||||
|
||||
#endif /* !LIB_H */
|
||||
|
@ -212,6 +212,7 @@ found:
|
||||
gfx_end();
|
||||
|
||||
sch_free(&sch_ctx);
|
||||
lib_free(&lib);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user