mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
cache: fix memory leak, add missing function
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
cce7098641
commit
25e7794f8f
1 changed files with 9 additions and 0 deletions
|
@ -34,6 +34,7 @@ static inline void _cache_invalidate(struct cache *c, struct cache_entry *e) {
|
|||
if (c->free) {
|
||||
c->free(c->user_data, e->value);
|
||||
}
|
||||
free(e->key);
|
||||
HASH_DEL(c->entries, e);
|
||||
free(e);
|
||||
}
|
||||
|
@ -60,3 +61,11 @@ void *cache_free(struct cache *c) {
|
|||
free(c);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct cache *new_cache(void *ud, cache_getter_t getter, cache_free_t f) {
|
||||
auto c = ccalloc(1, struct cache);
|
||||
c->user_data = ud;
|
||||
c->getter = getter;
|
||||
c->free = f;
|
||||
return c;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue