Commit 8c5a1b80 authored by Charlie Jacobsen's avatar Charlie Jacobsen

Fixes two minor memory leaks.

1 - Need to free name strings in cap types when we
    do cap_fini.

I decided to ran valgrind to check for any others.

2 - Need to free fake slab cache for user version.

There are a handful of innocuous leaks in the
multi_thrd_cap test app. There are also some innocuous
leaks reported due to glib's use of memory pooling (it appears).
parent d2d591e0
Pipeline #388 failed with stage
......@@ -70,9 +70,13 @@ static inline cap_cache_t *__cap_gslice_fakeslab_create(size_t size)
#define __cap_cache_create2(__struct,name) __cap_gslice_fakeslab_create(sizeof(struct __struct))
static inline void __cap_cache_destroy(cap_cache_t * cache)
{
/* Glib will just keep the pool around, I guess. I assume it
/*
* Glib will just keep the pool around, I guess. I assume it
* shrinks it periodically when g_slice_free1() is called.
*
* Free our fake slab cache.
*/
free(cache);
return;
}
......
......@@ -51,7 +51,17 @@ int cap_init(void)
void cap_fini(void)
{
int i;
/*
* Destroy cdt cache
*/
cap_cache_destroy(cdt_cache.cdt_root_cache);
/*
* Free up any strdup'd names in the cap_types array
*/
for (i = CAP_TYPE_FIRST_NONBUILTIN; i < CAP_TYPE_MAX; ++i)
if (cap_types[i].name)
free(cap_types[i].name);
}
cap_type_t cap_register_type(cap_type_t type, const struct cap_type_ops *ops)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment