1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-06-07 17:58:54 +03:00

eeshow/kicad/ext.c (clone_file_names, free_file_names): manage set of names

This commit is contained in:
Werner Almesberger 2016-08-22 22:18:46 -03:00
parent 417ddb16fa
commit e46f8382f3
2 changed files with 36 additions and 0 deletions

View File

@ -84,3 +84,37 @@ void classify_files(struct file_names *fn, char *const *args,
}
}
}
struct file_names *clone_file_names(const struct file_names *fn)
{
struct file_names *new;
unsigned i;
new = alloc_type(struct file_names);
new->pro = fn && fn->pro ? stralloc(fn->pro) : NULL;
new->sch = fn && fn->sch ? stralloc(fn->sch) : NULL;
new->pl = fn && fn->pl ? stralloc(fn->pl) : NULL;
new->n_libs = fn ? fn->n_libs : 0;
if (!fn) {
new->libs = NULL;
return new;
}
new->libs = alloc_type_n(const char *, fn->n_libs);
for (i = 0; i != fn->n_libs; i++)
new->libs[i] = stralloc(fn->libs[i]);
return new;
}
void free_file_names(struct file_names *fn)
{
unsigned i;
free((void *) fn->pro);
free((void *) fn->sch);
free((void *) fn->pl);
for (i = 0; i != fn->n_libs; i++)
free((void *) fn->libs[i]);
free(fn->libs);
}

View File

@ -35,5 +35,7 @@ struct file_names {
enum ext identify(const char *path);
void classify_files(struct file_names *fn, char *const *args,
unsigned n_args);
struct file_names *clone_file_names(const struct file_names *fn);
void free_file_names(struct file_names *fn);
#endif /* !KICAD_EXT_H */