1
0
Fork 0
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:
Yuxuan Shui 2019-05-05 04:55:42 +01:00
parent cce7098641
commit 25e7794f8f
No known key found for this signature in database
GPG key ID: 37C999F617EA1A47

View file

@ -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;
}