Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 4503) +++ trunk/scconfig/Rev.h (revision 4504) @@ -1 +1 @@ -static const int myrev = 4502; +static const int myrev = 4504; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 4503) +++ trunk/scconfig/Rev.tab (revision 4504) @@ -1,4 +1,4 @@ -4502 configure unravel - the big cleanup, moving code and files +4504 configure unravel - the big cleanup, moving code and files 4450 configure io_lihata plugin config and 3rd party lib dependency fix 4398 configure io_kicad plugin interdeps and enable io_kicad by default 4375 configure custom output style support in io_lihata Index: trunk/src/global.h =================================================================== --- trunk/src/global.h (revision 4503) +++ trunk/src/global.h (revision 4504) @@ -88,37 +88,6 @@ void *(*Rat) (RatTypePtr); } ObjectFunctionType, *ObjectFunctionTypePtr; -/* --------------------------------------------------------------------------- - * structure used by device drivers - */ - -typedef struct { /* holds a connection */ - Coord X, Y; /* coordinate of connection */ - long int type; /* type of object in ptr1 - 3 */ - void *ptr1, *ptr2; /* the object of the connection */ - pcb_cardinal_t group; /* the layer group of the connection */ - LibraryMenuType *menu; /* the netmenu this *SHOULD* belong too */ -} ConnectionType, *ConnectionTypePtr; - -struct net_st { /* holds a net of connections */ - pcb_cardinal_t ConnectionN, /* the number of connections contained */ - ConnectionMax; /* max connections from malloc */ - ConnectionTypePtr Connection; - RouteStyleTypePtr Style; -}; - -typedef struct { /* holds a list of nets */ - pcb_cardinal_t NetN, /* the number of subnets contained */ - NetMax; /* max subnets from malloc */ - NetTypePtr Net; -} NetListType, *NetListTypePtr; - -typedef struct { /* holds a list of net lists */ - pcb_cardinal_t NetListN, /* the number of net lists contained */ - NetListMax; /* max net lists from malloc */ - NetListTypePtr NetList; -} NetListListType, *NetListListTypePtr; - typedef struct { /* holds a generic list of pointers */ pcb_cardinal_t PtrN, /* the number of pointers contained */ PtrMax; /* max subnets from malloc */ Index: trunk/src/global_typedefs.h =================================================================== --- trunk/src/global_typedefs.h (revision 4503) +++ trunk/src/global_typedefs.h (revision 4504) @@ -34,7 +34,10 @@ typedef struct pcb_layer_group_s LayerGroupType, *LayerGroupTypePtr; typedef struct pcb_layer_s LayerType, *LayerTypePtr; typedef struct pcb_buffer_s BufferType, *BufferTypePtr; +typedef struct pcb_net_s NetType, *NetTypePtr; +typedef struct pcb_rat_s ConnectionType, *ConnectionTypePtr; + typedef struct BoxType BoxType, *BoxTypePtr; typedef struct polygon_st PolygonType, *PolygonTypePtr; typedef struct pad_st PadType, *PadTypePtr; @@ -42,8 +45,8 @@ typedef struct rtree rtree_t; typedef struct rats_patch_line_s rats_patch_line_t; typedef struct element_st ElementType, *ElementTypePtr, **ElementTypeHandle; -typedef struct net_st NetType, *NetTypePtr; + typedef struct data_st DataType, *DataTypePtr; typedef struct plug_io_s plug_io_t; Index: trunk/src/mymem.c =================================================================== --- trunk/src/mymem.c (revision 4503) +++ trunk/src/mymem.c (revision 4504) @@ -102,59 +102,7 @@ return (box + Boxes->BoxN++); } - /* --------------------------------------------------------------------------- - * get next slot for a connection, allocates memory if necessary - */ -ConnectionTypePtr GetConnectionMemory(NetTypePtr Net) -{ - ConnectionTypePtr con = Net->Connection; - - /* realloc new memory if necessary and clear it */ - if (Net->ConnectionN >= Net->ConnectionMax) { - Net->ConnectionMax += STEP_POINT; - con = (ConnectionTypePtr) realloc(con, Net->ConnectionMax * sizeof(ConnectionType)); - Net->Connection = con; - memset(con + Net->ConnectionN, 0, STEP_POINT * sizeof(ConnectionType)); - } - return (con + Net->ConnectionN++); -} - -/* --------------------------------------------------------------------------- - * get next slot for a subnet, allocates memory if necessary - */ -NetTypePtr GetNetMemory(NetListTypePtr Netlist) -{ - NetTypePtr net = Netlist->Net; - - /* realloc new memory if necessary and clear it */ - if (Netlist->NetN >= Netlist->NetMax) { - Netlist->NetMax += STEP_POINT; - net = (NetTypePtr) realloc(net, Netlist->NetMax * sizeof(NetType)); - Netlist->Net = net; - memset(net + Netlist->NetN, 0, STEP_POINT * sizeof(NetType)); - } - return (net + Netlist->NetN++); -} - -/* --------------------------------------------------------------------------- - * get next slot for a net list, allocates memory if necessary - */ -NetListTypePtr GetNetListMemory(NetListListTypePtr Netlistlist) -{ - NetListTypePtr netlist = Netlistlist->NetList; - - /* realloc new memory if necessary and clear it */ - if (Netlistlist->NetListN >= Netlistlist->NetListMax) { - Netlistlist->NetListMax += STEP_POINT; - netlist = (NetListTypePtr) realloc(netlist, Netlistlist->NetListMax * sizeof(NetListType)); - Netlistlist->NetList = netlist; - memset(netlist + Netlistlist->NetListN, 0, STEP_POINT * sizeof(NetListType)); - } - return (netlist + Netlistlist->NetListN++); -} - -/* --------------------------------------------------------------------------- * get next slot for a pin, allocates memory if necessary */ PinType *GetPinMemory(ElementType * element) @@ -440,49 +388,6 @@ } /* --------------------------------------------------------------------------- - * frees memory used by a net - */ -void FreeNetListMemory(NetListTypePtr Netlist) -{ - if (Netlist) { - NET_LOOP(Netlist); - { - FreeNetMemory(net); - } - END_LOOP; - free(Netlist->Net); - memset(Netlist, 0, sizeof(NetListType)); - } -} - -/* --------------------------------------------------------------------------- - * frees memory used by a net list - */ -void FreeNetListListMemory(NetListListTypePtr Netlistlist) -{ - if (Netlistlist) { - NETLIST_LOOP(Netlistlist); - { - FreeNetListMemory(netlist); - } - END_LOOP; - free(Netlistlist->NetList); - memset(Netlistlist, 0, sizeof(NetListListType)); - } -} - -/* --------------------------------------------------------------------------- - * frees memory used by a subnet - */ -void FreeNetMemory(NetTypePtr Net) -{ - if (Net) { - free(Net->Connection); - memset(Net, 0, sizeof(NetType)); - } -} - -/* --------------------------------------------------------------------------- * frees memory used by an attribute list */ static void FreeAttributeListMemory(AttributeListTypePtr list) Index: trunk/src/mymem.h =================================================================== --- trunk/src/mymem.h (revision 4503) +++ trunk/src/mymem.h (revision 4504) @@ -69,9 +69,6 @@ pcb_cardinal_t *GetHoleIndexMemoryInPolygon(PolygonTypePtr); ElementTypePtr GetElementMemory(DataTypePtr); BoxTypePtr GetBoxMemory(BoxListTypePtr); -ConnectionTypePtr GetConnectionMemory(NetTypePtr); -NetTypePtr GetNetMemory(NetListTypePtr); -NetListTypePtr GetNetListMemory(NetListListTypePtr); LibraryMenuTypePtr GetLibraryMenuMemory(LibraryTypePtr, int *idx); LibraryEntryTypePtr GetLibraryEntryMemory(LibraryMenuTypePtr); void **GetPointerMemory(PointerListTypePtr); @@ -79,9 +76,6 @@ void FreeElementMemory(ElementTypePtr); void FreePCBMemory(PCBTypePtr); void FreeBoxListMemory(BoxListTypePtr); -void FreeNetListListMemory(NetListListTypePtr); -void FreeNetListMemory(NetListTypePtr); -void FreeNetMemory(NetTypePtr); void FreeDataMemory(DataTypePtr); void FreeLibraryMemory(LibraryTypePtr); void FreePointerListMemory(PointerListTypePtr); Index: trunk/src/netlist.c =================================================================== --- trunk/src/netlist.c (revision 4503) +++ trunk/src/netlist.c (revision 4504) @@ -255,3 +255,80 @@ return net - first; } + +/* --------------------------------------------------------------------------- + * get next slot for a subnet, allocates memory if necessary + */ +NetTypePtr GetNetMemory(NetListTypePtr Netlist) +{ + NetTypePtr net = Netlist->Net; + + /* realloc new memory if necessary and clear it */ + if (Netlist->NetN >= Netlist->NetMax) { + Netlist->NetMax += STEP_POINT; + net = (NetTypePtr) realloc(net, Netlist->NetMax * sizeof(NetType)); + Netlist->Net = net; + memset(net + Netlist->NetN, 0, STEP_POINT * sizeof(NetType)); + } + return (net + Netlist->NetN++); +} + +/* --------------------------------------------------------------------------- + * get next slot for a net list, allocates memory if necessary + */ +NetListTypePtr GetNetListMemory(NetListListTypePtr Netlistlist) +{ + NetListTypePtr netlist = Netlistlist->NetList; + + /* realloc new memory if necessary and clear it */ + if (Netlistlist->NetListN >= Netlistlist->NetListMax) { + Netlistlist->NetListMax += STEP_POINT; + netlist = (NetListTypePtr) realloc(netlist, Netlistlist->NetListMax * sizeof(NetListType)); + Netlistlist->NetList = netlist; + memset(netlist + Netlistlist->NetListN, 0, STEP_POINT * sizeof(NetListType)); + } + return (netlist + Netlistlist->NetListN++); +} + +/* --------------------------------------------------------------------------- + * frees memory used by a net + */ +void FreeNetListMemory(NetListTypePtr Netlist) +{ + if (Netlist) { + NET_LOOP(Netlist); + { + FreeNetMemory(net); + } + END_LOOP; + free(Netlist->Net); + memset(Netlist, 0, sizeof(NetListType)); + } +} + +/* --------------------------------------------------------------------------- + * frees memory used by a net list + */ +void FreeNetListListMemory(NetListListTypePtr Netlistlist) +{ + if (Netlistlist) { + NETLIST_LOOP(Netlistlist); + { + FreeNetListMemory(netlist); + } + END_LOOP; + free(Netlistlist->NetList); + memset(Netlistlist, 0, sizeof(NetListListType)); + } +} + +/* --------------------------------------------------------------------------- + * frees memory used by a subnet + */ +void FreeNetMemory(NetTypePtr Net) +{ + if (Net) { + free(Net->Connection); + memset(Net, 0, sizeof(NetType)); + } +} Index: trunk/src/netlist.h =================================================================== --- trunk/src/netlist.h (revision 4503) +++ trunk/src/netlist.h (revision 4504) @@ -24,9 +24,32 @@ * */ +#ifndef PCB_NETLIST_H +#define PCB_NETLIST_H + /* generic netlist operations */ #include "global.h" +struct pcb_net_s { /* holds a net of connections */ + pcb_cardinal_t ConnectionN, /* the number of connections contained */ + ConnectionMax; /* max connections from malloc */ + ConnectionTypePtr Connection; + RouteStyleTypePtr Style; +}; + +typedef struct { /* holds a list of nets */ + pcb_cardinal_t NetN, /* the number of subnets contained */ + NetMax; /* max subnets from malloc */ + NetTypePtr Net; +} NetListType, *NetListTypePtr; + +typedef struct { /* holds a list of net lists */ + pcb_cardinal_t NetListN, /* the number of net lists contained */ + NetListMax; /* max net lists from malloc */ + NetListTypePtr NetList; +} NetListListType, *NetListListTypePtr; + + void pcb_netlist_changed(int force_unfreeze); LibraryMenuTypePtr pcb_netnode_to_netname(const char *nodename); LibraryMenuTypePtr pcb_netname_to_netname(const char *netname); @@ -61,3 +84,11 @@ pcb_cardinal_t pcb_netlist_net_idx(PCBTypePtr pcb, LibraryMenuType *net); #define PCB_NETLIST_INVALID_INDEX ((pcb_cardinal_t)(-1)) + +NetTypePtr GetNetMemory(NetListTypePtr); +NetListTypePtr GetNetListMemory(NetListListTypePtr); +void FreeNetListListMemory(NetListListTypePtr); +void FreeNetListMemory(NetListTypePtr); +void FreeNetMemory(NetTypePtr); + +#endif Index: trunk/src/rats.c =================================================================== --- trunk/src/rats.c (revision 4503) +++ trunk/src/rats.c (revision 4504) @@ -920,3 +920,20 @@ strcat(name, UNKNOWN(num)); return (name); } + +/* --------------------------------------------------------------------------- + * get next slot for a connection, allocates memory if necessary + */ +ConnectionTypePtr GetConnectionMemory(NetTypePtr Net) +{ + ConnectionTypePtr con = Net->Connection; + + /* realloc new memory if necessary and clear it */ + if (Net->ConnectionN >= Net->ConnectionMax) { + Net->ConnectionMax += STEP_POINT; + con = (ConnectionTypePtr) realloc(con, Net->ConnectionMax * sizeof(ConnectionType)); + Net->Connection = con; + memset(con + Net->ConnectionN, 0, STEP_POINT * sizeof(ConnectionType)); + } + return (con + Net->ConnectionN++); +} Index: trunk/src/rats.h =================================================================== --- trunk/src/rats.h (revision 4503) +++ trunk/src/rats.h (revision 4504) @@ -28,11 +28,25 @@ /* prototypes for rats routines */ -#ifndef PCB_RATS_H -#define PCB_RATS_H +#ifndef PCB_RATS_H +#define PCB_RATS_H #include "global.h" +#include "netlist.h" +/* --------------------------------------------------------------------------- + * structure used by device drivers + */ + + +struct pcb_rat_s { /* holds a connection (rat) */ + Coord X, Y; /* coordinate of connection */ + long int type; /* type of object in ptr1 - 3 */ + void *ptr1, *ptr2; /* the object of the connection */ + pcb_cardinal_t group; /* the layer group of the connection */ + LibraryMenuType *menu; /* the netmenu this *SHOULD* belong too */ +}; + RatTypePtr AddNet(void); char *ConnectionName(int, void *, void *); @@ -41,5 +55,6 @@ NetListTypePtr ProcNetlist(LibraryTypePtr); NetListListType CollectSubnets(pcb_bool); +ConnectionTypePtr GetConnectionMemory(NetTypePtr); #endif