void PoolAllocator::free(ID p_mem) { mt_lock(); Entry *e = get_entry(p_mem); if (!e) { mt_unlock(); ERR_PRINT("!e"); return; } if (e->lock) { mt_unlock(); ERR_PRINT("e->lock"); return; } EntryIndicesPos entry_indices_pos; bool index_found = find_entry_index(&entry_indices_pos, e); if (!index_found) { mt_unlock(); ERR_FAIL_COND(!index_found); } for (int i = entry_indices_pos; i < (entry_count - 1); i++) { entry_indices[i] = entry_indices[i + 1]; } entry_count--; free_mem += aligned(e->len); e->clear(); mt_unlock(); }
oc::result<void> SonyElfFormatWriter::get_entry(File &file, Entry &entry) { OUTCOME_TRYV(m_seg->get_entry(file, entry, m_writer)); auto swentry = m_seg->entry(); // Silently handle cmdline entry if (swentry->type == SONY_ELF_ENTRY_CMDLINE) { entry.clear(); entry.set_size(m_cmdline.size()); auto set_as_fatal = finally([&] { m_writer.set_fatal(); }); OUTCOME_TRYV(write_entry(file, entry)); OUTCOME_TRYV(write_data(file, m_cmdline.data(), m_cmdline.size())); OUTCOME_TRYV(finish_entry(file)); OUTCOME_TRYV(get_entry(file, entry)); set_as_fatal.dismiss(); } return oc::success(); }
bool ServerConfig::read(const char *filename) { // We depend on the XML parser to validate. // The asserts are only the ultimate way out. F*X f*x; F*X::Element *arch, *doc = f*x.parse(filename); if (!doc) { LOG_MSG("ServerConfig: Cannot parse '%s'\n", filename); return false; } LOG_ASSERT(doc->getName() == "serverconfig"); Entry entry; stdList<F*X::Element *>::const_iterator archs, e; for (archs=doc->getChildren().begin(); archs!=doc->getChildren().end(); ++archs) { arch = *archs; LOG_ASSERT(arch->getName() == "archive"); e = arch->getChildren().begin(); LOG_ASSERT((*e)->getName() == "key"); entry.key = atoi((*e)->getValue().c_str()); ++e; LOG_ASSERT((*e)->getName() == "name"); entry.name = (*e)->getValue(); ++e; LOG_ASSERT((*e)->getName() == "path"); entry.path = (*e)->getValue(); config.push_back(entry); entry.clear(); } return true; }
bool Processes::find ( Entry& entry ) { entry.clear(); const ::BOOL result = ::Process32FirstW(handle(), &entry.data()); if ( result == FALSE ) { const ::DWORD error = ::GetLastError(); UNCHECKED_WIN32C_ERROR(Process32FirstW, error); } return (true); }
bool Processes::next ( Entry& entry ) { entry.clear(); const ::BOOL result = ::Process32NextW(handle(), &entry.data()); if ( result == FALSE ) { const ::DWORD error = ::GetLastError(); if ( error == ERROR_NO_MORE_FILES ) { return (false); } UNCHECKED_WIN32C_ERROR(Process32FirstW, error); } return (true); }
void DefineEntry::accept() { #ifdef DEBUG qDebug("DefineEntry::accpet()"); #endif if (!EntryProperties->count()) { QMessageBox::warning(this, "No properties", "Please, define some entry's\nproperties", 0, 0, 0); return; } if (EntryName->text() == "") { QMessageBox::warning(this, "No entry name", "Please, define entry name", 0, 0, 0); return; } Entries *entries = IQApp->entries(); Entry *entry; if (editEntry) { if (EntryName->text() != editEntry->getName() && entries->isIn(EntryName->text())) { QMessageBox::warning(this, "Entry exists", "Entry with such name\nexists. Please, choose another.", 0, 0, 0); return; } entry = editEntry; entry->clear(); entry->setName(EntryName->text()); } else if ((entry = entries->isIn(EntryName->text()))) { QMessageBox::warning(this, "Entry exists", "Entry with such name\nexists. Please, choose another.", 0, 0, 0); return; } else entry = new Entry(EntryName->text()); for (uint i = 0; true; i++) { PropertyBoxItem *pbi; if ((pbi = static_cast<PropertyBoxItem *>(EntryProperties->item(i)))) { entry->addProperty(new PropertyStruct(pbi)); } else break; } entry->setDefaultPic(defaultPic); if (!editEntry) entries->addEntry(entry); entry->checkPropertiesID(); DefineEntryBase::accept(); }