void HeapContainer<NodeType,CostType,PlannerSpecificVariables>::remove (SearchGraphNode<NodeType,CostType,PlannerSpecificVariables>* np) { key_remove(np); if (np->prev) // Not at the beginning np->prev->nxt = np->nxt; else start = np->nxt; if (np->nxt) np->nxt->prev = np->prev; else end = np->prev; np->nxt = NULL; np->prev = NULL; np->inHeap = false; heap_size--; }
static void h_free_hd(HDATA* hd) { if(hd->refs > 0) hd->refs--; // still references open or caching requests it stays - do not release. if(hd->refs > 0 || hd->keep_open) return; // actually release the resource (call dtor, free control block). // h_alloc makes sure type != 0; if we get here, it still is H_VTbl* vtbl = hd->type; // call its destructor // note: H_TYPE_DEFINE currently always defines a dtor, but play it safe if(vtbl->dtor) vtbl->dtor(hd->user); if(hd->key && !hd->unique) key_remove(hd->key, hd->type); #ifndef NDEBUG // to_string is slow for some handles, so avoid calling it if unnecessary if(debug_filter_allows(L"H_MGR|")) { wchar_t buf[H_STRING_LEN]; if(vtbl->to_string(hd->user, buf) < 0) wcscpy_s(buf, ARRAY_SIZE(buf), L"(error)"); debug_printf(L"H_MGR| free %ls %ls accesses=%lu %ls\n", hd->type->name, hd->pathname.string().c_str(), (unsigned long)hd->num_derefs, buf); } #endif hd->pathname.~VfsPath(); // FIXME: ugly hack, but necessary to reclaim memory memset(hd, 0, sizeof(*hd)); pool_free(&hpool, hd); }
SearchGraphNode<NodeType,CostType,PlannerSpecificVariables>* HeapContainer<NodeType,CostType,PlannerSpecificVariables>::pop(void) { heapItem_p ret; ret = end; key_remove(ret); if (heap_size > 1) { end = end->prev; end->nxt = NULL; ret->prev = NULL; ret->inHeap = false; heap_size--; } else if (heap_size==1) { start = NULL; end = NULL; ret->inHeap = false; heap_size--; } return ret; }