mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-29 18:51:15 -03:00
Squash a leak in LRU caches
This commit is contained in:
2
env.cpp
2
env.cpp
@@ -1005,7 +1005,7 @@ static int try_remove( env_node_t *n,
|
||||
has_changed = 1;
|
||||
}
|
||||
|
||||
n->env.erase(result);
|
||||
n->env.erase(result);
|
||||
delete v;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -624,7 +624,9 @@ void history_t::save_internal()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Make sure we clear all nodes, since this doesn't happen automatically */
|
||||
lru.evict_all_nodes();
|
||||
|
||||
if( fclose( out ) || !ok )
|
||||
{
|
||||
|
||||
12
iothread.cpp
12
iothread.cpp
@@ -142,7 +142,7 @@ int iothread_perform_base(int (*handler)(void *), void (*completionCallback)(voi
|
||||
iothread_init();
|
||||
|
||||
/* 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->handler = handler;
|
||||
req->completionCallback = completionCallback;
|
||||
@@ -186,10 +186,12 @@ void iothread_service_completion(void) {
|
||||
s_active_thread_count -= 1;
|
||||
|
||||
/* Handle the request */
|
||||
if (req && req->completionCallback) {
|
||||
req->completionCallback(req->context, req->handlerResult);
|
||||
}
|
||||
|
||||
if (req) {
|
||||
if (req->completionCallback)
|
||||
req->completionCallback(req->context, req->handlerResult);
|
||||
delete req;
|
||||
}
|
||||
|
||||
/* Maybe spawn another thread, if there's more work to be done. */
|
||||
VOMIT_ON_FAILURE(pthread_mutex_lock(&s_request_queue_lock));
|
||||
iothread_spawn_if_needed();
|
||||
|
||||
3
lru.h
3
lru.h
@@ -101,6 +101,9 @@ class lru_cache_t {
|
||||
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 */
|
||||
node_type_t *get_node(const wcstring &key) {
|
||||
node_type_t *result = NULL;
|
||||
|
||||
Reference in New Issue
Block a user