int AddToMap(Map* mp, char* key, void* value) { if (!mp) return 0; List* ls = FindInHashTable(mp->tb,key); if (!ls) { ls = InitList(); if (!InsertIntoHashTable(mp->tb,key,ls)) { printf("Warning(Map): cannot insert %s into hash table!\n",key); return 0; } mp->size++; } if (!AppendToList(ls,value)) { printf("Warning(Map): cannot append to list!\n"); return 0; } return 1; }
jc_uint NewGotoLabel(CJcGotoStack * pStack, jc_char* sLabelName, jc_uint nOffset) { jc_char* skey; jc_uint *pGotoAddr, *pOffset; CJcGotoTable* pTable = pStack->pGotoTable; if(!pTable) return 1; pGotoAddr = (jc_uint*)SearchInHashTable(pTable->pLabelTable, sLabelName); if(pGotoAddr) return 1; skey = (jc_char*)g_oInterface.Malloc(StringLength(sLabelName)+1); StringCopy(skey, sLabelName); pOffset = New(jc_uint); pOffset[0] = nOffset; InsertIntoHashTable(pTable->pLabelTable, skey, pOffset); return 0; }