Index: trunk/src/plug_footprint.c =================================================================== --- trunk/src/plug_footprint.c (revision 33257) +++ trunk/src/plug_footprint.c (revision 33258) @@ -56,23 +56,12 @@ 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; + vtp0_t *vt = ((parent) == NULL ? &pcb_library.data.dir.children : &(parent)->data.dir.children); - res = vtlib_alloc_append(vt, 1); + res = calloc(sizeof(pcb_fplibrary_t), 1); res->parent = parent; + vtp0_append(vt, res); - 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; } @@ -239,15 +228,16 @@ pcb_fplibrary_t *fp_lib_search_len(pcb_fplibrary_t *dir, const char *name, int name_len) { - pcb_fplibrary_t *l; int n; if (dir->type != PCB_LIB_DIR) return NULL; - for(n = 0, l = dir->data.dir.children.array; n < dir->data.dir.children.used; n++, l++) + for(n = 0; n < dir->data.dir.children.used; n++) { + pcb_fplibrary_t *l = dir->data.dir.children.array[n]; if (strncmp(l->name, name, name_len) == 0) return l; + } return NULL; } @@ -254,15 +244,16 @@ pcb_fplibrary_t *pcb_fp_lib_search(pcb_fplibrary_t *dir, const char *name) { - pcb_fplibrary_t *l; int n; if (dir->type != PCB_LIB_DIR) return NULL; - for(n = 0, l = dir->data.dir.children.array; n < dir->data.dir.children.used; n++, l++) + for(n = 0; n < dir->data.dir.children.used; n++) { + pcb_fplibrary_t *l = dir->data.dir.children.array[n]; if (strcmp(l->name, name) == 0) return l; + } return NULL; } @@ -278,7 +269,7 @@ l->name = rnd_strdup(name); l->type = PCB_LIB_DIR; l->data.dir.backend = NULL; - vtlib_init(&l->data.dir.children); + vtp0_init(&l->data.dir.children); return l; } @@ -331,14 +322,14 @@ static int fp_sort_cb(const void *a, const void *b) { - const pcb_fplibrary_t *fa = a, *fb = b; - int res = strcmp(fa->name, fb->name); + const pcb_fplibrary_t **fa = a, **fb = b; + int res = strcmp((*fa)->name, (*fb)->name); return res == 0 ? 1 : res; } void pcb_fp_sort_children(pcb_fplibrary_t *parent) { - vtlib_t *v; + vtp0_t *v; int n, i; if (parent->type != PCB_LIB_DIR) @@ -345,13 +336,10 @@ return; v = &parent->data.dir.children; - qsort(v->array, vtlib_len(v), sizeof(pcb_fplibrary_t), fp_sort_cb); + qsort(v->array, vtp0_len(v), sizeof(pcb_fplibrary_t *), fp_sort_cb); - 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]); - } + for (n = 0; n < vtp0_len(v); n++) + pcb_fp_sort_children(v->array[n]); } void fp_free_entry(pcb_fplibrary_t *l) @@ -359,7 +347,7 @@ switch(l->type) { case PCB_LIB_DIR: pcb_fp_free_children(l); - vtlib_uninit(&(l->data.dir.children)); + vtp0_uninit(&(l->data.dir.children)); break; case PCB_LIB_FOOTPRINT: if (l->data.fp.loc_info != NULL) @@ -379,14 +367,15 @@ void pcb_fp_free_children(pcb_fplibrary_t *parent) { int n; - pcb_fplibrary_t *l; assert(parent->type == PCB_LIB_DIR); - for(n = 0, l = parent->data.dir.children.array; n < parent->data.dir.children.used; n++, l++) + for(n = 0; n < parent->data.dir.children.used; n++) { + pcb_fplibrary_t *l = parent->data.dir.children.array[n]; fp_free_entry(l); + } - vtlib_truncate(&(parent->data.dir.children), 0); + vtp0_truncate(&(parent->data.dir.children), 0); } @@ -396,9 +385,10 @@ int n; fp_free_entry(dir); if (parent != NULL) { - for(n = 0, l = parent->data.dir.children.array; n < parent->data.dir.children.used; n++,l++) { + for(n = 0; n < parent->data.dir.children.used; n++) { + l = parent->data.dir.children.array[n]; if (l == dir) { - vtlib_remove(&(parent->data.dir.children), n, 1); + vtp0_remove(&(parent->data.dir.children), n, 1); break; } } @@ -408,10 +398,11 @@ /* Debug functions */ void fp_dump_dir(pcb_fplibrary_t *dir, int level) { - pcb_fplibrary_t *l; int n, p; - for(n = 0, l = dir->data.dir.children.array; n < dir->data.dir.children.used; n++, l++) { + for(n = 0; n < dir->data.dir.children.used; n++) { + pcb_fplibrary_t *l = dir->data.dir.children.array[0]; + for(p = 0; p < level; p++) putchar(' '); if (l->type == PCB_LIB_DIR) { Index: trunk/src/vtlibrary.c =================================================================== --- trunk/src/vtlibrary.c (revision 33257) +++ trunk/src/vtlibrary.c (revision 33258) @@ -1,3 +1 @@ -#define GVT_DONT_UNDEF -#include "vtlibrary.h" -#include +static int pcb_vtlibrary_dummy; Index: trunk/src/vtlibrary.h =================================================================== --- trunk/src/vtlibrary.h (revision 33257) +++ trunk/src/vtlibrary.h (revision 33258) @@ -2,6 +2,7 @@ #define PCB_VTLIBRARY_H #include #include +#include typedef enum { PCB_LIB_INVALID, @@ -20,41 +21,6 @@ typedef struct pcb_fplibrary_s pcb_fplibrary_t; -/* Elem=library_t; init=none */ - -/* all public symbols are wrapped in GVT() - see vt_t(7) */ -#define GVT(x) vtlib_ ## x - -/* Array elem type - see vt_t(7) */ -#define GVT_ELEM_TYPE pcb_fplibrary_t - -/* Type that represents array lengths - see vt_t(7) */ -#define GVT_SIZE_TYPE size_t - -/* Below this length, always double allocation size when the array grows */ -#define GVT_DOUBLING_THRS 64 - -/* Initial array size when the first element is written */ -#define GVT_START_SIZE 8 - -/* Optional prefix for function definitions (e.g. static inline) */ -#define GVT_FUNC - -/* Enable this to set all new bytes ever allocated to this value - see - vt_set_new_bytes_to(7) */ -#define GVT_SET_NEW_BYTES_TO 0 - - -/* Include the actual header implementation */ -#include - -/* Memory allocator - see vt_allocation(7) */ -#define GVT_REALLOC(vect, ptr, size) realloc(ptr, size) -#define GVT_FREE(vect, ptr) free(ptr) - -/* clean up #defines */ -#include - /* An element of a library: either a directory or a footprint */ struct pcb_fplibrary_s { char *name; /* visible name */ @@ -63,7 +29,7 @@ union { struct { /* type == LIB_DIR */ - vtlib_t children; + vtp0_t children; /* of (pcb_fplibrary_t *) */ void *backend; /* pcb_plug_fp_t* */ } dir; struct { /* type == LIB_FOOTPRINT */ Index: trunk/src_plugins/dialogs/dlg_library.c =================================================================== --- trunk/src_plugins/dialogs/dlg_library.c (revision 33257) +++ trunk/src_plugins/dialogs/dlg_library.c (revision 33258) @@ -259,11 +259,11 @@ static void create_lib_tree_model_recurse(rnd_hid_attribute_t *attr, pcb_fplibrary_t *parent_lib, rnd_hid_row_t *parent_row) { char *cell[2]; - pcb_fplibrary_t *l; int n; cell[1] = NULL; - for(l = parent_lib->data.dir.children.array, n = 0; n < parent_lib->data.dir.children.used; l++, n++) { + for(n = 0; n < parent_lib->data.dir.children.used; n++) { + pcb_fplibrary_t *l = parent_lib->data.dir.children.array[n]; rnd_hid_row_t *row; cell[0] = rnd_strdup(l->name); Index: trunk/src_plugins/oldactions/oldactions.c =================================================================== --- trunk/src_plugins/oldactions/oldactions.c (revision 33257) +++ trunk/src_plugins/oldactions/oldactions.c (revision 33258) @@ -83,8 +83,8 @@ ind(level); printf("%s/\n", l->name); - for(n = 0; n < vtlib_len(&l->data.dir.children); n++) - dump_lib_any(level+1, l->data.dir.children.array+n); + for(n = 0; n < vtp0_len(&l->data.dir.children); n++) + dump_lib_any(level+1, l->data.dir.children.array[n]); } static void dump_lib_fp(int level, pcb_fplibrary_t *l) Index: trunk/tests/pcb-printf/Makefile =================================================================== --- trunk/tests/pcb-printf/Makefile (revision 33257) +++ trunk/tests/pcb-printf/Makefile (revision 33258) @@ -13,7 +13,7 @@ LDLIBS = -lm GDS= $(TRUNK)/src_3rd/genvector/gds_char.o -LIBPCB_BASE= $(LIBRND)/core/unit.o $(LIBRND)/core/compat_misc.o +LIBPCB_BASE= $(LIBRND)/core/unit.o $(LIBRND)/core/misc_util.o $(LIBRND)/core/compat_misc.o test: tester.diff