Index: abstract.c =================================================================== --- abstract.c (revision 709) +++ abstract.c (revision 710) @@ -38,15 +38,24 @@ memset(abs, 0, sizeof(csch_abstract_t)); htsp_init(&abs->nets, strhash, strkeyeq); htsp_init(&abs->comps, strhash, strkeyeq); + htip_init(&abs->aid2obj, longhash, longkeyeq); + abs->next_aid = 1; } /* Initialize an object by setting the common header fields; the only purpose of this function is to get compiler warnings at every caller when the header is extended (because the number of args would be extended here) */ -csch_inline void csch_aobj_init(csch_ahdr_t *dst, csch_atype_t type) +csch_inline void csch_aobj_init(csch_abstract_t *abs, csch_ahdr_t *dst, csch_atype_t type) { dst->type = type; csch_attrib_init(&dst->attr); + + /* assign unique aid */ + dst->aid = abs->next_aid; + abs->next_aid++; + if (abs->next_aid < 1) + abs->next_aid = 1; + htip_set(&abs->aid2obj, dst->aid, dst); } csch_anet_t *csch_anet_get(csch_abstract_t *abs, const char *netname, int alloc) @@ -58,7 +67,7 @@ return net; net = calloc(sizeof(csch_anet_t), 1); - csch_aobj_init(&net->hdr, CSCH_ATYPE_NET); + csch_aobj_init(abs, &net->hdr, CSCH_ATYPE_NET); net->netname = csch_strdup(netname); htsp_set(&abs->nets, net->netname, net); return net; @@ -73,7 +82,7 @@ return comp; comp = calloc(sizeof(csch_acomp_t), 1); - csch_aobj_init(&comp->hdr, CSCH_ATYPE_COMP); + csch_aobj_init(abs, &comp->hdr, CSCH_ATYPE_COMP); comp->name = csch_strdup(name); htsp_set(&abs->comps, comp->name, comp); htsp_init(&comp->ports, strhash, strkeyeq); @@ -89,7 +98,7 @@ return port; port = calloc(sizeof(csch_aport_t), 1); - csch_aobj_init(&port->hdr, CSCH_ATYPE_PORT); + csch_aobj_init(abs, &port->hdr, CSCH_ATYPE_PORT); port->name = csch_strdup(name); htsp_set(&comp->ports, port->name, port); return port;