8 weeks ago
add saf function map cleanup
--- a/src/server/daemon/config.c Thu Jan 30 18:29:30 2025 +0100 +++ b/src/server/daemon/config.c Thu Jan 30 18:54:43 2025 +0100 @@ -1159,7 +1159,7 @@ // add the type for each extension to the map for(int i=0;i<d->nextensions;i++) { cxstring ext = d->extensions[i]; - cxmutstr value = cx_strdup(cx_strn(d->type.ptr, d->type.length)); + cxmutstr value = cx_strdup_a(cfg->a, cx_strn(d->type.ptr, d->type.length)); if(cxMapPut(map, cx_hash_key_bytes((const unsigned char *)ext.ptr, ext.length), value.ptr)) { log_ereport(LOG_CATASTROPHE, "OOM"); ret = -1;
--- a/src/server/daemon/func.c Thu Jan 30 18:29:30 2025 +0100 +++ b/src/server/daemon/func.c Thu Jan 30 18:54:43 2025 +0100 @@ -38,8 +38,18 @@ CxMap *function_map; +static void funcstruct_free(FuncStruct *f) { + free((char*)f->name); + free(f); +} + void func_init() { function_map = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 256); + function_map->simple_destructor = (cx_destructor_func)funcstruct_free; +} + +void func_cleanup() { + cxMapDestroy(function_map); } void add_function(FuncStruct *func) {
--- a/src/server/daemon/func.h Thu Jan 30 18:29:30 2025 +0100 +++ b/src/server/daemon/func.h Thu Jan 30 18:54:43 2025 +0100 @@ -40,6 +40,7 @@ (f)->func(pb, sn, rq) void func_init(); +void func_cleanup(); void add_function(struct FuncStruct *func);
--- a/src/server/daemon/webserver.c Thu Jan 30 18:29:30 2025 +0100 +++ b/src/server/daemon/webserver.c Thu Jan 30 18:54:43 2025 +0100 @@ -297,9 +297,7 @@ free(re); re = re_next; } - - resource_pool_cleanup(); - + webserver_destroy(); } @@ -347,6 +345,12 @@ // however it will result in a nicer valgrind output with less // memory leaks pool_destroy(cfg_get_init_pool()); + + resource_pool_cleanup(); + func_cleanup(); + + ServerConfiguration *scfg = cfgmgr_get_server_config(); + pool_destroy(scfg->pool); } int nsapi_runtime_version() {