mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00:00
Squash a leak in LRU caches
This commit is contained in:
parent
3b56c58f00
commit
51da4856e2
4 changed files with 14 additions and 7 deletions
|
@ -625,6 +625,8 @@ void history_t::save_internal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure we clear all nodes, since this doesn't happen automatically */
|
||||||
|
lru.evict_all_nodes();
|
||||||
|
|
||||||
if( fclose( out ) || !ok )
|
if( fclose( out ) || !ok )
|
||||||
{
|
{
|
||||||
|
|
|
@ -142,7 +142,7 @@ int iothread_perform_base(int (*handler)(void *), void (*completionCallback)(voi
|
||||||
iothread_init();
|
iothread_init();
|
||||||
|
|
||||||
/* Create and initialize a request. */
|
/* Create and initialize a request. */
|
||||||
struct ThreadedRequest_t *req = (struct ThreadedRequest_t *)malloc(sizeof *req);
|
struct ThreadedRequest_t *req = new ThreadedRequest_t();
|
||||||
req->next = NULL;
|
req->next = NULL;
|
||||||
req->handler = handler;
|
req->handler = handler;
|
||||||
req->completionCallback = completionCallback;
|
req->completionCallback = completionCallback;
|
||||||
|
@ -186,8 +186,10 @@ void iothread_service_completion(void) {
|
||||||
s_active_thread_count -= 1;
|
s_active_thread_count -= 1;
|
||||||
|
|
||||||
/* Handle the request */
|
/* Handle the request */
|
||||||
if (req && req->completionCallback) {
|
if (req) {
|
||||||
|
if (req->completionCallback)
|
||||||
req->completionCallback(req->context, req->handlerResult);
|
req->completionCallback(req->context, req->handlerResult);
|
||||||
|
delete req;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Maybe spawn another thread, if there's more work to be done. */
|
/* Maybe spawn another thread, if there's more work to be done. */
|
||||||
|
|
3
lru.h
3
lru.h
|
@ -101,6 +101,9 @@ class lru_cache_t {
|
||||||
mouth.prev = mouth.next = &mouth;
|
mouth.prev = mouth.next = &mouth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Note that we do not define a destructor. We cannot evict all nodes (even though they typically need to be deleted by their creator). */
|
||||||
|
|
||||||
|
|
||||||
/** Returns the node for a given key, or NULL */
|
/** Returns the node for a given key, or NULL */
|
||||||
node_type_t *get_node(const wcstring &key) {
|
node_type_t *get_node(const wcstring &key) {
|
||||||
node_type_t *result = NULL;
|
node_type_t *result = NULL;
|
||||||
|
|
Loading…
Reference in a new issue