Index: trunk/src/data.h =================================================================== --- trunk/src/data.h (revision 12116) +++ trunk/src/data.h (revision 12117) @@ -46,6 +46,7 @@ int LayerN; /* number of layers in this board */ pcb_vtpadstack_proto_t ps_protos; + unsigned long ps_next_grp; /* next group number to allocate; if 0, have to figure */ padstacklist_t padstack; pinlist_t Via; Index: trunk/src/obj_padstack.c =================================================================== --- trunk/src/obj_padstack.c (revision 12116) +++ trunk/src/obj_padstack.c (revision 12117) @@ -22,9 +22,26 @@ #include "config.h" +#include "data.h" #include "obj_padstack.h" +unsigned long pcb_padstack_alloc_group(pcb_data_t *data) +{ + pcb_cardinal_t n; + unsigned long mg; + if (data->ps_next_grp > 0) /* cheap way: answer in cache */ + return data->ps_next_grp++; + + for(n = 0, mg = 0; n < pcb_vtpadstack_proto_len(&data->ps_protos); n++) + if (data->ps_protos.array[n].group > mg) + mg = data->ps_protos.array[n].group; + + data->ps_next_grp = mg+1; + + return data->ps_next_grp++; +} + /*** hash ***/ static unsigned int pcb_padstack_shape_hash(const pcb_padstack_shape_t *sh) { Index: trunk/src/obj_padstack.h =================================================================== --- trunk/src/obj_padstack.h (revision 12116) +++ trunk/src/obj_padstack.h (revision 12117) @@ -76,6 +76,9 @@ unsigned long group; } pcb_padstack_proto_t; +/* allocate and return the next available group ID */ +unsigned long pcb_padstack_alloc_group(pcb_data_t *data); + /*** hash ***/ unsigned int pcb_padstack_hash(const pcb_padstack_proto_t *p); int pcb_padstack_eq(const pcb_padstack_proto_t *p1, const pcb_padstack_proto_t *p2);