bool hfile::close() { if (!mHandle || !Pool().is_used(mHandle)) { assert("HFILE: Invalid Handle"==0); return false; } SOpenFile& sfile = Pool()[mHandle]; if (sfile.mHandle==0) { assert("HFILE: Unable TO Close Unopened File"==0); return false; } if (!HFILEclose(sfile.mHandle)) { sfile.mHandle = 0; assert("HFILE: Unable To Close File"==0); return false; } sfile.mHandle = 0; return true; }
bool hfile::is_open(void) const { if (mHandle && Pool().is_used(mHandle)) { return (Pool()[mHandle].mHandle!=0); } return false; }
bool hfile::is_open_for_write(void) const { if (mHandle && Pool().is_used(mHandle)) { SOpenFile& sfile = Pool()[mHandle]; return (sfile.mHandle!=0 && !sfile.mForRead); } return false; }
void CacheStorageService::PurgeOverMemoryLimit() { MOZ_ASSERT(IsOnManagementThread()); LOG(("CacheStorageService::PurgeOverMemoryLimit")); Pool(true).PurgeOverMemoryLimit(); Pool(false).PurgeOverMemoryLimit(); }
//////////////////////////////////////////////////////////////////////////////////////// // Destructor // // Releases the open file structure for resue. Also closes the file if open. // //////////////////////////////////////////////////////////////////////////////////////// hfile::~hfile() { if (is_open()) { close(); } if (mHandle && Pool().is_used(mHandle)) { Pool().free(mHandle); } mHandle = 0; }
global_func void OnFileSearch(bool isdirname, string _tmp_ name, void* data) { BxString Name(name); // 안전을 위해 재귀처리는 새로운 공간할당이 필요 if(!isdirname) { if(Name.GetFileExt().CompareNoCase("downloading") != same) { Pool()[LAST].Path = Name.CloneWithAlloc(); PoolSumSize() += (Pool()[END].Size = BxCore::File::GetSize(Name)); Pool()[END].Date = BxCore::File::GetDate(Name); } } else BxCore::File::SearchFiles(Name, OnFileSearch, data); }
void hstring::init(const char *str) { if (!str) { mHandle = 0; } else { mHandle = Pool().get_handle(str, strlen(str)+1); // +1 for null character } #ifdef _DEBUG mStr = (char*)Pool()[mHandle]; #endif }
static PyObject *fs_root_file_contents(FileSystemRootObject *self, PyObject *args) { svn_stream_t *stream; apr_pool_t *pool; StreamObject *ret; char *path; if (!PyArg_ParseTuple(args, "s", &path)) return NULL; pool = Pool(NULL); if (pool == NULL) return NULL; RUN_SVN_WITH_POOL(pool, svn_fs_file_contents(&stream, self->root, path, pool)); ret = PyObject_New(StreamObject, &Stream_Type); if (ret == NULL) return NULL; ret->pool = pool; ret->closed = FALSE; ret->stream = stream; return (PyObject *)ret; }
static PyObject *repos_verify(RepositoryObject *self, PyObject *args) { apr_pool_t *temp_pool; PyObject *py_feedback_stream; svn_revnum_t start_rev, end_rev; svn_stream_t *stream; if (!PyArg_ParseTuple(args, "Oll", &py_feedback_stream, &start_rev, &end_rev)) return NULL; temp_pool = Pool(NULL); if (temp_pool == NULL) { return NULL; } stream = new_py_stream(temp_pool, py_feedback_stream); if (stream == NULL) { apr_pool_destroy(temp_pool); return NULL; } RUN_SVN_WITH_POOL(temp_pool, svn_repos_verify_fs(self->repos, stream, start_rev, end_rev, py_cancel_check, NULL, temp_pool)); apr_pool_destroy(temp_pool); Py_RETURN_NONE; }
static PyObject *fs_get_revision_root(FileSystemObject *self, PyObject *args) { svn_revnum_t rev; FileSystemRootObject *ret; apr_pool_t *pool; svn_fs_root_t *root; if (!PyArg_ParseTuple(args, "l", &rev)) return NULL; pool = Pool(NULL); if (pool == NULL) return NULL; RUN_SVN_WITH_POOL(pool, svn_fs_revision_root(&root, self->fs, rev, pool)); ret = PyObject_New(FileSystemRootObject, &FileSystemRoot_Type); if (ret == NULL) return NULL; ret->root = root; ret->pool = pool; return (PyObject *)ret; }
xmrig::CommonConfig::CommonConfig() : m_algorithm(CRYPTONIGHT, VARIANT_AUTO), m_adjusted(false), m_apiIPv6(false), m_apiRestricted(true), m_autoSave(true), m_background(false), m_colors(true), m_dryRun(false), m_syslog(false), # ifdef XMRIG_PROXY_PROJECT m_watch(true), # else m_watch(false), // TODO: enable config file watch by default when this feature propertly handled and tested. # endif m_apiPort(0), m_donateLevel(kDefaultDonateLevel), m_printTime(60), m_retries(5), m_retryPause(5), m_state(NoneState) { m_pools.push_back(Pool()); # ifdef XMRIG_PROXY_PROJECT m_retries = 2; m_retryPause = 1; # endif }
static PyObject *py_editor_open_root(PyObject *self, PyObject *args) { svn_revnum_t base_revision=-1; void *root_baton; EditorObject *editor = (EditorObject *)self; apr_pool_t *subpool; if (!PyArg_ParseTuple(args, "|l:open_root", &base_revision)) return NULL; if (editor->done) { PyErr_SetString(PyExc_RuntimeError, "Editor already closed/aborted"); return NULL; } RUN_SVN(editor->editor->open_root(editor->baton, base_revision, editor->pool, &root_baton)); subpool = Pool(NULL); if (subpool == NULL) return NULL; return new_editor_object(editor, editor->editor, root_baton, subpool, &DirectoryEditor_Type, NULL, NULL, NULL); }
void SqlPool::add_source(const SqlSource &source) { sources_[source.id()] = source; counts_[source.id()] = 0; pools_[source.id()] = Pool(); }
//////////////////////////////////////////////////////////////////////////////////////// // Constructor // // Allocates a new OpenFile structure and initializes it. DOES NOT OPEN! // //////////////////////////////////////////////////////////////////////////////////////// hfile::hfile(const char* file) { if (Pool().full()) { mHandle = 0; assert("HFILE: Too Many Files Open, Unable To Grab An Unused Handle"==0); return; } mHandle = Pool().alloc(); SOpenFile& sfile = Pool()[mHandle]; sfile.mPath = file; sfile.mHandle = 0; sfile.mForRead = true; }
const char* hstring::c_str(void) const { if (!mHandle) { return(""); } return ((const char*)Pool()[mHandle]); }
size_t CacheStorageService::SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { CacheStorageService::Self()->Lock().AssertCurrentThreadOwns(); size_t n = 0; // The elemets are referenced by sGlobalEntryTables and are reported from there n += Pool(true).mFrecencyArray.SizeOfExcludingThis(mallocSizeOf); n += Pool(true).mExpirationArray.SizeOfExcludingThis(mallocSizeOf); n += Pool(false).mFrecencyArray.SizeOfExcludingThis(mallocSizeOf); n += Pool(false).mExpirationArray.SizeOfExcludingThis(mallocSizeOf); // Entries reported manually in CacheStorageService::CollectReports callback if (sGlobalEntryTables) { n += sGlobalEntryTables->SizeOfIncludingThis(nullptr, mallocSizeOf); } return n; }
static PyObject *fs_root_paths_changed(FileSystemRootObject *self) { apr_pool_t *temp_pool; apr_hash_t *changed_paths; const char *key; apr_ssize_t klen; apr_hash_index_t *idx; PyObject *ret; temp_pool = Pool(NULL); if (temp_pool == NULL) return NULL; #if ONLY_SINCE_SVN(1, 6) RUN_SVN_WITH_POOL(temp_pool, svn_fs_paths_changed2(&changed_paths, self->root, temp_pool)); #else RUN_SVN_WITH_POOL(temp_pool, svn_fs_paths_changed(&changed_paths, self->root, temp_pool)); #endif ret = PyDict_New(); if (ret == NULL) { apr_pool_destroy(temp_pool); return NULL; } for (idx = apr_hash_first(temp_pool, changed_paths); idx != NULL; idx = apr_hash_next(idx)) { PyObject *py_val; #if ONLY_SINCE_SVN(1, 6) svn_fs_path_change2_t *val; #else svn_fs_path_change_t *val; #endif apr_hash_this(idx, (const void **)&key, &klen, (void **)&val); #if ONLY_SINCE_SVN(1, 6) py_val = py_fs_path_change2(val); #else py_val = py_fs_path_change(val); #endif if (py_val == NULL) { apr_pool_destroy(temp_pool); PyObject_Del(ret); return NULL; } if (PyDict_SetItemString(ret, key, py_val) != 0) { apr_pool_destroy(temp_pool); PyObject_Del(ret); Py_DECREF(py_val); return NULL; } Py_DECREF(py_val); } apr_pool_destroy(temp_pool); return ret; }
ParsedDetails HtmlApi::parseDetails(const QString &source, Site *site) const { Q_UNUSED(site); ParsedDetails ret; // Pools if (contains("Regex/Pools")) { QRegularExpression rx(value("Regex/Pools")); auto matches = rx.globalMatch(source); while (matches.hasNext()) { auto match = matches.next(); QString previous = match.captured(1), id = match.captured(2), name = match.captured(3), next = match.captured(4); ret.pools.append(Pool(id.toInt(), name, 0, next.toInt(), previous.toInt())); } } // Tags QString rxtags; if (contains("Regex/ImageTags")) { rxtags = value("Regex/ImageTags"); } else if (contains("Regex/Tags")) { rxtags = value("Regex/Tags"); } if (!rxtags.isEmpty()) { ret.tags = Tag::FromRegexp(rxtags, source); } // Image url if (contains("Regex/ImageUrl")) { QRegularExpression rx(value("Regex/ImageUrl")); auto matches = rx.globalMatch(source); while (matches.hasNext()) { auto match = matches.next(); ret.imageUrl = match.captured(1).replace("&", "&"); } } // Image date if (contains("Regex/ImageDate")) { QRegularExpression rx(value("Regex/ImageDate")); auto matches = rx.globalMatch(source); while (matches.hasNext()) { auto match = matches.next(); ret.createdAt = qDateTimeFromString(match.captured(1)); } } return ret; }
static PyObject *py_string_from_svn_node_id(const svn_fs_id_t *id) { apr_pool_t *temp_pool; svn_string_t *str; temp_pool = Pool(NULL); if (temp_pool == NULL) return NULL; str = svn_fs_unparse_id(id, temp_pool); if (str == NULL) { apr_pool_destroy(temp_pool); return NULL; } return PyBytes_FromStringAndSize(str->data, str->len); }
static PyObject *fs_get_youngest_revision(FileSystemObject *self) { svn_revnum_t rev; apr_pool_t *temp_pool; PyObject *ret; temp_pool = Pool(NULL); if (temp_pool == NULL) return NULL; RUN_SVN_WITH_POOL(temp_pool, svn_fs_youngest_rev(&rev, self->fs, temp_pool)); ret = py_from_svn_revnum(rev); apr_pool_destroy(temp_pool); return ret; }
//////////////////////////////////////////////////////////////////////////////////// // Searches for the first block with the matching data size, and reads it in. //////////////////////////////////////////////////////////////////////////////////// bool hfile::load(void* data, int datasize) { // Go Ahead And Open The File For Reading //---------------------------------------- bool auto_opened = false; if (!is_open()) { if (!open_read()) { return false; } auto_opened = true; } // Make Sure That The File Is Readable //------------------------------------- SOpenFile& sfile = Pool()[mHandle]; if (!sfile.mForRead) { assert("HFILE: Unable to load from a file that is opened for save"==0); if (auto_opened) { close(); } return false; } // Now Read It //------------- if (!HFILEread(sfile.mHandle, data, datasize)) { assert("HFILE: Unable To Read Object"==0); if (auto_opened) { close(); } return false; } // Success! //---------- if (auto_opened) { close(); } return true; }
static PyObject *py_abspath(PyObject *self, PyObject *args) { const char *path; PyObject *py_path, *ret; apr_pool_t *pool; if (!PyArg_ParseTuple(args, "O", &py_path)) return NULL; pool = Pool(NULL); path = py_object_to_svn_abspath(py_path, pool); ret = PyUnicode_FromString(path); apr_pool_destroy(pool); return ret; }
static PyObject *py_uri_canonicalize(PyObject *self, PyObject *args) { const char *uri; PyObject *py_uri, *ret; apr_pool_t *pool; if (!PyArg_ParseTuple(args, "O", &py_uri)) return NULL; pool = Pool(NULL); uri = py_object_to_svn_uri(py_uri, pool); ret = PyUnicode_FromString(uri); apr_pool_destroy(pool); return ret; }
static PyObject *fs_get_uuid(PyObject *self) { FileSystemObject *fsobj = (FileSystemObject *)self; const char *uuid; PyObject *ret; apr_pool_t *temp_pool; temp_pool = Pool(NULL); if (temp_pool == NULL) return NULL; RUN_SVN_WITH_POOL(temp_pool, svn_fs_get_uuid(fsobj->fs, &uuid, temp_pool)); ret = PyUnicode_FromString(uuid); apr_pool_destroy(temp_pool); return ret; }
static PyObject *py_dirent_canonicalize(PyObject *self, PyObject *args) { const char *dirent; PyObject *py_dirent, *ret; apr_pool_t *pool; if (!PyArg_ParseTuple(args, "O", &py_dirent)) return NULL; pool = Pool(NULL); dirent = py_object_to_svn_dirent(py_dirent, pool); ret = PyUnicode_FromString(dirent); apr_pool_destroy(pool); return ret; }
void CacheStorageService::RegisterEntry(CacheEntry* aEntry) { MOZ_ASSERT(IsOnManagementThread()); if (mShutdown || !aEntry->CanRegister()) return; LOG(("CacheStorageService::RegisterEntry [entry=%p]", aEntry)); MemoryPool& pool = Pool(aEntry->IsUsingDisk()); pool.mFrecencyArray.InsertElementSorted(aEntry, FrecencyComparator()); pool.mExpirationArray.InsertElementSorted(aEntry, ExpirationComparator()); aEntry->SetRegistered(true); }
static PyObject *py_dir_editor_add_directory(PyObject *self, PyObject *args) { PyObject *py_path, *py_copyfrom_path = Py_None; const char *path; const char *copyfrom_path = NULL; svn_revnum_t copyfrom_rev = -1; void *child_baton; EditorObject *editor = (EditorObject *)self; apr_pool_t *subpool; if (!PyArg_ParseTuple(args, "O|Ol", &py_path, &py_copyfrom_path, ©from_rev)) return NULL; if (editor->done) { PyErr_SetString(PyExc_RuntimeError, "directory editor already closed"); return NULL; } if (editor->active_child) { PyErr_SetString(PyExc_RuntimeError, "child is already open"); return NULL; } path = py_object_to_svn_relpath(py_path, editor->pool); if (path == NULL) { return NULL; } if (py_copyfrom_path != Py_None) { copyfrom_path = py_object_to_svn_uri(py_copyfrom_path, editor->pool); if (copyfrom_path == NULL) { return NULL; } } RUN_SVN(editor->editor->add_directory( path, editor->baton, copyfrom_path == NULL?NULL:svn_uri_canonicalize(copyfrom_path, editor->pool), copyfrom_rev, editor->pool, &child_baton)); subpool = Pool(editor->pool); if (subpool == NULL) return NULL; return new_editor_object(editor, editor->editor, child_baton, subpool, &DirectoryEditor_Type, NULL, NULL, NULL); }
void xmrig::CommonConfig::fixup() { if (m_state == NoneState) { return; } if (m_pools.empty()) { if (!m_activePools.empty()) { std::swap(m_pools, m_activePools); } else { m_pools.push_back(Pool()); } m_state = NoneState; } }
void DecisionTree::computeTree(Pool& pool) { double max =0; int varChosen=0; std::vector<int> occurrencesInResp(pool.levelSize()); for(int j=0;j<pool.levelSize();j++) occurrencesInResp[j] = pool.idxs(j).size(); double firstTerm = entropy(occurrencesInResp,pool.sampleSize()); for(int i=0;i<matComp.size();i++) { double calc = infoGain(matComp[i],pool,firstTerm); if(calc>=max) { max = calc; varChosen = i; } } if(max>0) { pool.setVarIdx(varChosen); pool.setInfoGain(max); int splits = matComp[varChosen].levelSize(); for(int j=0;j<splits;j++) { std::vector<int> descIdxs = matComp[varChosen].idxs(j); std::vector<int> respIdxs = pool.allIdxs(); std::vector<int> intersec; intersec.reserve(pool.sampleSize()); std::set_intersection(descIdxs.begin(),descIdxs.end(),respIdxs.begin(), respIdxs.end(),std::back_inserter(intersec)); pool.add_node(Pool(intersec,pool.labsFromIdx(intersec),matComp[varChosen].getLevel(j))); Pool& poolToCheck = pool.getNext(j); if(poolToCheck.levelSize()<=1) continue; else computeTree(poolToCheck); } } }
bool M8MPoolConnectingApp::AddPool(const PoolInfo ©, const CanonicalInfo &algoInfo) { pools.push_back(Pool()); pools.back().config = copy; pools.back().source = std::make_unique<WorkSource>(copy.name, algoInfo, std::make_pair(copy.diffMode, copy.diffMul), copy.merkleMode); auto &source(*pools.back().source); source.AddCredentials(copy.user, copy.pass); source.errorCallback = [this](const AbstractWorkSource &owner, asizei i, int errorCode, const std::string &message) { StratumError(owner, i, errorCode, message); }; source.shareResponseCallback = [this](const AbstractWorkSource &me, asizei shareID, StratumShareResponse stat) { ShareResponse(me, shareID, stat); }; source.workerAuthCallback = [this](const AbstractWorkSource &owner, const std::string &worker, StratumState::AuthStatus status) { WorkerAuthorization(owner, worker, status); }; return true; }