Index: trunk/src/plug_footprint.c =================================================================== --- trunk/src/plug_footprint.c (revision 33144) +++ trunk/src/plug_footprint.c (revision 33145) @@ -53,6 +53,30 @@ pcb_plug_fp_t *pcb_plug_fp_chain = NULL; pcb_fplibrary_t pcb_library; +static pcb_fplibrary_t *pcb_get_library_memory(pcb_fplibrary_t *parent) +{ + pcb_fplibrary_t *res; + vtlib_t *vt = ((parent) == NULL ? &pcb_library.data.dir.children : &(parent)->data.dir.children); + void *old = vt->array; + + res = vtlib_alloc_append(vt, 1); + res->parent = parent; + + if (vt->array != old) { /* if the vector array had to be relocated, update all parent pointers */ + long n, i; +TODO("TODO39: replace vtlib with vtp0 so no need to update parents"); + for(n = 0; n < vt->used; n++) { + pcb_fplibrary_t *l = &vt->array[n]; + if (l->type == PCB_LIB_DIR) + for(i = 0; i < l->data.dir.children.used; i++) + l->data.dir.children.array[i].parent = l; + } + } + + return res; +} + + int pcb_fp_dupname(const char *name, char **basename, char **params) { char *newname, *s; @@ -252,7 +276,6 @@ l->name = rnd_strndup(name, name_len); else l->name = rnd_strdup(name); - l->parent = parent; l->type = PCB_LIB_DIR; l->data.dir.backend = NULL; vtlib_init(&l->data.dir.children); @@ -316,7 +339,7 @@ void pcb_fp_sort_children(pcb_fplibrary_t *parent) { vtlib_t *v; - int n; + int n, i; if (parent->type != PCB_LIB_DIR) return; @@ -324,8 +347,11 @@ v = &parent->data.dir.children; qsort(v->array, vtlib_len(v), sizeof(pcb_fplibrary_t), fp_sort_cb); - for (n = 0; n < vtlib_len(v); n++) + for (n = 0; n < vtlib_len(v); n++) { + for(i = 0; i < v->used; i++) /* TODO39 */ + v->array[i].parent = parent; pcb_fp_sort_children(&v->array[n]); + } } void fp_free_entry(pcb_fplibrary_t *l) Index: trunk/src/plug_footprint.h =================================================================== --- trunk/src/plug_footprint.h (revision 33144) +++ trunk/src/plug_footprint.h (revision 33145) @@ -75,8 +75,6 @@ extern pcb_fplibrary_t pcb_library; /* the footprint library */ -#define pcb_get_library_memory(parent) vtlib_alloc_append(((parent) == NULL ? &pcb_library.data.dir.children : &(parent)->data.dir.children), 1); - void pcb_fp_free_children(pcb_fplibrary_t *parent); void pcb_fp_sort_children(pcb_fplibrary_t *parent); void pcb_fp_rmdir(pcb_fplibrary_t *dir);