void LefTechInit() { HashSearch hs; HashEntry *he; lefLayer *lefl; if (LefInfo.ht_table != (HashEntry **) NULL) { HashStartSearch(&hs); while (he = HashNext(&LefInfo, &hs)) { lefl = (lefLayer *)HashGetValue(he); if (!lefl) continue; lefl->refCnt--; if (lefl->refCnt <= 0) { /* Via detailed information, if it exists, */ /* needs to have its allocated memory free'd. */ if (lefl->lefClass == CLASS_VIA) if (lefl->info.via.lr != NULL) freeMagic(lefl->info.via.lr); freeMagic(lefl); } } HashKill(&LefInfo); } HashInit(&LefInfo, 32, HT_STRINGKEYS); }
//============================================================== static int objTask(sTaskBody *body, int msg, int lParam, int rParam) //-------------------------------------------------------------- // タスク処理 //-------------------------------------------------------------- // in: body = ハンドル // msg = メッセージ // lParam, rParam = 汎用パラメータ //-------------------------------------------------------------- // out: 実行結果 //============================================================== { int res = 0; switch(msg) { case MSG_CREATE: { param_hash = HashCreate("obj"); obj_link = ObjLinkCreate(sizeof(sOBJ), OBJ_NUM, MEM_SYS, FALSE); SYSINFO(".... object initialize"); } break; case MSG_KILL: { ObjDeleteParamAll(); HashKill(param_hash); ObjLinkDestroy(obj_link); SYSINFO(".... object finish"); } break; case MSG_PREPROC: { { sOBJ *obj; obj = ObjGetNext(NULL, OBJ_TYPE_ALL, NULL); while(obj) { obj->create = FALSE; obj = ObjGetNext(obj, OBJ_TYPE_ALL, NULL); } } ObjPostMsgAll(OBJ_TYPE_ALL, msg, FALSE, 0, 0); } break; case MSG_STEP: { ObjPostMsgAll(OBJ_TYPE_ALL, msg, FALSE, 0, 0); { sOBJ *obj; obj = ObjGetNext(NULL, OBJ_TYPE_ALL, NULL); while(obj) { sOBJ *next; next = ObjGetNext(obj, OBJ_TYPE_ALL, NULL); if(obj->kill_req) objDelete(obj); obj = next; } } } break; case MSG_UPDATE: { ObjPostMsgAll(OBJ_TYPE_ALL, msg, FALSE, 0, 0); } break; case MSG_DRAW: { ObjPostMsgAll(OBJ_TYPE_ALL, msg, FALSE, 0, 0); } break; default: { ObjPostMsgAll(OBJ_TYPE_ALL, msg, FALSE, lParam, rParam); } break; } return res; }
void EFDone() { Connection *conn; HashSearch hs; HashEntry *he; Kill *kill; Def *def; Use *use; Dev *dev; int n; HashStartSearch(&hs); while (he = HashNext(&efDefHashTable, &hs)) { def = (Def *) HashGetValue(he); freeMagic(def->def_name); efFreeNodeTable(&def->def_nodes); efFreeNodeList(&def->def_firstn); HashKill(&def->def_nodes); HashKill(&def->def_dists); for (use = def->def_uses; use; use = use->use_next) { freeMagic(use->use_id); freeMagic((char *) use); } for (conn = def->def_conns; conn; conn = conn->conn_next) efFreeConn(conn); for (conn = def->def_caps; conn; conn = conn->conn_next) efFreeConn(conn); for (conn = def->def_resistors; conn; conn = conn->conn_next) efFreeConn(conn); for (dev = def->def_devs; dev; dev = dev->dev_next) { for (n = 0; n < (int)dev->dev_nterm; n++) if (dev->dev_terms[n].dterm_attrs) freeMagic((char *) dev->dev_terms[n].dterm_attrs); freeMagic((char *) dev); } for (kill = def->def_kills; kill; kill = kill->kill_next) { freeMagic(kill->kill_name); freeMagic((char *) kill); } freeMagic((char *) def); } /* Misc cleanup */ for (n = 0; n < EFDevNumTypes; n++) freeMagic(EFDevTypes[n]); /* Changed from n = 0 to n = 1; First entry "space" is predefined, */ /* not malloc'd. ---Tim 9/3/02 */ for (n = 1; n < EFLayerNumNames; n++) freeMagic(EFLayerNames[n]); if (EFTech) { freeMagic(EFTech); EFTech = (char *)NULL; } /* Free up all HierNames that were stored in efFreeHashTable */ /* HashStartSearch(&hs); while (he = HashNext(&efFreeHashTable, &hs)) freeMagic(he->h_key.h_ptr); */ /* Free up the parameter name tables for each device */ HashStartSearch(&hs); while (he = HashNext(&efDevParamTable, &hs)) { DevParam *plist = (DevParam *)HashGetValue(he); while (plist != NULL) { freeMagic(plist->parm_name); freeMagic(plist); plist = plist->parm_next; } } HashKill(&efDevParamTable); HashKill(&efFreeHashTable); /* Final cleanup */ HashKill(&efDefHashTable); }