summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-22 22:18:46 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-22 22:18:46 -0300
commit57c459e51bf1625f33e7545b7b682c14bb982a08 (patch)
tree4acf6d171fa550093af903a277688aa06110694c /kicad
parent125606db21189d9d9e3f7580889d0b7c2400f6ad (diff)
downloadeeshow-57c459e51bf1625f33e7545b7b682c14bb982a08.tar.gz
eeshow-57c459e51bf1625f33e7545b7b682c14bb982a08.tar.bz2
eeshow-57c459e51bf1625f33e7545b7b682c14bb982a08.zip
eeshow/kicad/ext.c (clone_file_names, free_file_names): manage set of names
Diffstat (limited to 'kicad')
-rw-r--r--kicad/ext.c34
-rw-r--r--kicad/ext.h2
2 files changed, 36 insertions, 0 deletions
diff --git a/kicad/ext.c b/kicad/ext.c
index 15d4e75..d4221ee 100644
--- a/kicad/ext.c
+++ b/kicad/ext.c
@@ -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);
+}
diff --git a/kicad/ext.h b/kicad/ext.h
index 0986edd..603b9e0 100644
--- a/kicad/ext.h
+++ b/kicad/ext.h
@@ -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 */