void SimFieldDictionary::setFieldValue(StringTableEntry slotName, const char *value) { U32 bucket = getHashValue(slotName); Entry **walk = &mHashTable[bucket]; while(*walk && (*walk)->slotName != slotName) walk = &((*walk)->next); Entry *field = *walk; if( !value || !*value ) { if(field) { mVersion++; if( field->value ) dFree(field->value); *walk = field->next; freeEntry(field); } } else { if(field) { if( field->value ) dFree(field->value); field->value = dStrdup(value); } else addEntry( bucket, slotName, 0, dStrdup( value ) ); } }
void RemoveEntryCommand::redo() { freeEntry(); const QModelIndex index = makeIndex(); m_isExpanded = m_view->isExpanded(index); m_entry = m_view->removeEntry(index); }
StoreEntry* allocateEntry(JNIEnv* env, Store* rStore, jstring rKey) { LOGV("allocateEntry is called"); int32_t error = 0; StoreEntry* rEntry = findEntry(env, rStore, rKey, &error); if(rEntry != NULL) freeEntry(env, rEntry); else if(!error) { LOGV("No error while allocation"); if(rStore->numentries >= STORE_MAX_CAPACITY) { LOGV("Store is full"); throwStoreFullException(env); return NULL; } rEntry = rStore->allentries + rStore->numentries; const char* tmpKeyString = (*env)->GetStringUTFChars(env, rKey, NULL); if(tmpKeyString == NULL) return NULL; rEntry->nKey = (char*) malloc(strlen(tmpKeyString)); strcpy(rEntry->nKey, tmpKeyString); (*env)->ReleaseStringUTFChars(env, rKey, tmpKeyString); rStore->numentries++; } return rEntry; }
void freeHashTab(HASHTAB t) { int i; HASHENTRY e,e1; for (i = 0; i < HASHSIZE; i++) { for (e = t->tab[i]; e != NULL; e = e1) { e1 = e->next; freeEntry(e); } } dispose_structured_flat((OBJ)t); }
void InMemoryStorage::eraseImpl(const Name& name) { auto it = m_cache.get<byFullName>().find(name); if (it == m_cache.get<byFullName>().end()) return; freeEntry(it); }
void RemoveEntryCommand::undo() { if (m_entry == 0) { m_entry->restore(); Q_ASSERT(m_view != 0); const QModelIndex index = makeIndex(); m_view->setExpanded(index, m_isExpanded); m_view->setCurrentIndex(index); freeEntry(); } }
void TickCache::dropOldest() { AssertFatal(mTickCacheHead->oldest,"Popping off too many tick cache entries"); TickCacheEntry * oldest = mTickCacheHead->oldest; mTickCacheHead->oldest = oldest->next; if (oldest->move) freeMove(oldest->move); freeEntry(oldest); mTickCacheHead->numEntry--; if (mTickCacheHead->numEntry < 2) mTickCacheHead->newest = mTickCacheHead->oldest; }
void TickCache::dropNextOldest() { AssertFatal(mTickCacheHead->oldest && mTickCacheHead->numEntry>1,"Popping off too many tick cache entries"); TickCacheEntry * oldest = mTickCacheHead->oldest; TickCacheEntry * nextoldest = mTickCacheHead->oldest->next; oldest->next = nextoldest->next; if (nextoldest->move) freeMove(nextoldest->move); freeEntry(nextoldest); mTickCacheHead->numEntry--; if (mTickCacheHead->numEntry==1) mTickCacheHead->newest = mTickCacheHead->oldest; }
void InMemoryStorage::erase(const Name& prefix, const bool isPrefix) { if (isPrefix) { auto it = m_cache.get<byFullName>().lower_bound(prefix); while (it != m_cache.get<byFullName>().end() && prefix.isPrefixOf((*it)->getName())) { // let derived class do something with the entry beforeErase(*it); it = freeEntry(it); } } else { auto it = m_cache.get<byFullName>().find(prefix); if (it == m_cache.get<byFullName>().end()) return; // let derived class do something with the entry beforeErase(*it); freeEntry(it); } if (m_freeEntries.size() > (2 * size())) setCapacity(getCapacity() / 2); }
InMemoryStorage::~InMemoryStorage() { // evict all items from cache Cache::iterator it = m_cache.begin(); while (it != m_cache.end()) { it = freeEntry(it); } BOOST_ASSERT(m_freeEntries.size() == m_capacity); while (!m_freeEntries.empty()) { delete m_freeEntries.top(); m_freeEntries.pop(); } }
void CloneTable::freeAtAddress(SegManager *segMan, reg_t addr) { #ifdef GC_DEBUG Object *victim_obj = &(_table[addr.offset]); if (!(victim_obj->_flags & OBJECT_FLAG_FREED)) warning("[GC] Clone %04x:%04x not reachable and not freed (freeing now)", PRINT_REG(addr)); #ifdef GC_DEBUG_VERBOSE else warning("[GC-DEBUG] Clone %04x:%04x: Freeing", PRINT_REG(addr)); warning("[GC] Clone had pos %04x:%04x", PRINT_REG(victim_obj->pos)); #endif #endif freeEntry(addr.offset); }
SimFieldDictionary::~SimFieldDictionary() { for(U32 i = 0; i < HashTableSize; i++) { for(Entry *walk = mHashTable[i]; walk;) { Entry *temp = walk; walk = temp->next; if( temp->value ) dFree(temp->value); freeEntry(temp); } } AssertFatal( mNumFields == 0, "Incorrect count on field dictionary" ); }
void ArrayTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) { _table[sub_addr.offset].destroy(); freeEntry(sub_addr.offset); }
RemoveEntryCommand::~RemoveEntryCommand() { freeEntry(); }
/* * Function: * freeEntryItem * * Description: * Frees the memory allocated to an Item of the type Entry * * Arguments: * Pointer to the item * Item item * * Return value: * None. */ void freeEntryItem(Item item) { freeEntry((Entry *) item); }
//-------------------- nodes -------------------- void NodeTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) { freeEntry(sub_addr.offset); }
void iregisterdllfun(void) { int i, index; ResType argtypes[MAX_ARGS]; /* list of types of arguments */ bool vararg[MAX_ARGS]; /* is the argument a variable arg */ bool ispointer[MAX_ARGS]; /* is the argument a pointer */ int varargcount = 0; /* number of variable args */ int ispointercount = 0; /* number of pointer args */ nialptr z = apop(); char *nialname; /* names used by calldllfun */ char *dllname; /* the real name of the function */ /* in the DLL file */ char *library; /* name of the DLL file */ ResType resulttype; /* the type of the result */ nialptr nargtypes; /* the arg type array */ int argcount; int j; int sz; nialptr current; /* usually hold the current entry in the dlllist */ int is_register; /* if we have 5 args we are registering a function */ if ((tally(z) == 5) && (kind(z) == atype)) is_register = 1; /* register mode */ else /* only one arg and it is a char or a phrase, we are deleting the fun */ if ((kind(z) == chartype) || (kind(z) == phrasetype)) is_register = 0; /* delete mode */ else { /* error mode */ apush(makefault("?Incorrect number of arguments to registerdllfun")); freeup(z); return; } if (is_register) { /* The Nial level name for the DLL function */ STRING_CHECK(z, 0) nialname = STRING_GET(z, 0); /* The internal DLL name for the function */ STRING_CHECK(z, 1) dllname = STRING_GET(z, 1); /* The name of the library file */ STRING_CHECK(z, 2) library = STRING_GET(z, 2); /* The name of the result type */ STRING_CHECK(z, 3) resulttype = StringToTypeID(STRING_GET(z, 3)); /* did we find an unrecognized result type? */ if (resulttype < 0) { apush(makefault("?Return type not recognized")); freeup(z); return; } if (kind(fetch_array(z, 4)) != atype) { apush(makefault("?Argument must be a list of strings or phrases")); freeup(z); return; } nargtypes = fetch_array(z, 4); argcount = tally(nargtypes); /* Check each of the argument type */ for (j = 0; j < argcount; j++) STRING_CHECK_FREEUP(nargtypes, j, z) /* create an integer list of argument types from the phrase/string list */ for (i = 0; i < argcount; i++) { char *tmp; tmp = pfirstchar(fetch_array(nargtypes, i)); /* safe: no allocation */ argtypes[i] = StringToTypeID(tmp); /* the ith argument name was not recognized */ if (argtypes[i] < 0) { char stmp[256]; wsprintf(stmp, "?Type \"%s\" for argument %d not recognized", tmp, i + 1); apush(makefault(stmp)); freeup(z); return; } /* set the vararg and ispointer flags for this arg */ vararg[i] = IsVarArg(tmp); ispointer[i] = IsPointer(tmp); /* keep count of these special args */ if (vararg[i]) varargcount++; if (ispointer[i]) ispointercount++; } /* NEW workspace Version */ /* If the list does not yet exist, then create a one element list here */ if (tally(dlllist) == 0) { nialptr tmp = create_new_dll_entry; /* build a empty entry */ setup_dll_entry(tmp) /* fill it with empty data */ apush(tmp); isolitary(); /* make it a list */ decrrefcnt(dlllist); freeup(dlllist); dlllist = apop(); incrrefcnt(dlllist); index = 0; } else { int pos; /* does the requested name already exist in out list? */ if ((pos = inlist(nialname)) >= 0) { /* yes it's here already, so note its position, and free the old * entry */ index = pos; freeEntry(index); } else { /* if we got here, then we need to create a new entry and add it to * and existing dlllist */ nialptr tmp = create_new_dll_entry; setup_dll_entry(tmp) decrrefcnt(dlllist); append(dlllist, tmp); dlllist = apop(); incrrefcnt(dlllist); index = tally(dlllist) - 1; /* this is the location of the new entry */ } } /* grab the entry to work on */ current = fetch_array(dlllist, index); /* fill in data */ set_handle(current, NULL); set_nialname(current, nialname); set_dllname(current, dllname); set_callingconvention(current, (dllname[0] == '_' ? C_CALL : PASCAL_CALL)); set_library(current, library); set_isloaded(current, false); set_resulttype(current, resulttype); set_argcount(current, argcount); set_varargcount(current, varargcount); set_ispointercount(current, ispointercount); sz = argcount; replace_array(current, 10, (sz == 0 ? Null : new_create_array(inttype, 1, 0, &sz))); for (j = 0; j < sz; j++) set_argtypes(current, j, argtypes[j]); replace_array(current, 11, (sz == 0 ? Null : new_create_array(booltype, 1, 0, &sz))); for (j = 0; j < sz; j++) set_ispointer(current, j, ispointer[j]); replace_array(current, 14, (sz == 0 ? Null : new_create_array(booltype, 1, 0, &sz))); for (j = 0; j < sz; j++) set_vararg(current, j, vararg[j]); } else { /* delete entry code */