diff --git a/libs/gamecode/pr_debug.c b/libs/gamecode/pr_debug.c index e80cb72a7..7b774e9b1 100644 --- a/libs/gamecode/pr_debug.c +++ b/libs/gamecode/pr_debug.c @@ -1988,9 +1988,17 @@ PR_Debug_Init (progs_t *pr) pr->pr_debug_resources = res; } +static void +pr_debug_shutdown (void *data) +{ + free (source_paths); + free (source_path_string); +} + void PR_Debug_Init_Cvars (void) { + Sys_RegisterShutdown (pr_debug_shutdown, 0); Cvar_Register (&pr_debug_cvar, 0, 0); Cvar_Register (&pr_source_path_cvar, source_path_f, 0); } diff --git a/libs/gamecode/pr_strings.c b/libs/gamecode/pr_strings.c index b4227fc64..5e00746ac 100644 --- a/libs/gamecode/pr_strings.c +++ b/libs/gamecode/pr_strings.c @@ -40,6 +40,7 @@ #include #include +#include "QF/darray.h" #include "QF/dstring.h" #include "QF/hash.h" #include "QF/progs.h" @@ -88,6 +89,7 @@ typedef struct prstr_resources_s { unsigned dyn_str_size; struct hashtab_s *strref_hash; int num_strings; + struct DARRAY_TYPE (fmt_item_t *) fmt_item_blocks; fmt_item_t *free_fmt_items; dstring_t *print_str; prstr_at_handler_t at_handler; @@ -248,6 +250,11 @@ pr_strings_destroy (progs_t *pr, void *_res) } free (res->string_map); + for (size_t i = 0; i < res->fmt_item_blocks.size; i++) { + free (res->fmt_item_blocks.a[i]); + } + DARRAY_CLEAR (&res->fmt_item_blocks); + pr->pr_string_resources = 0; free (res); } @@ -848,6 +855,7 @@ new_fmt_item (prstr_resources_t *res) for (i = 0; i < 15; i++) res->free_fmt_items[i].next = res->free_fmt_items + i + 1; res->free_fmt_items[i].next = 0; + DARRAY_APPEND (&res->fmt_item_blocks, res->free_fmt_items); } fi = res->free_fmt_items; @@ -1300,6 +1308,7 @@ PR_Strings_Init (progs_t *pr) res->print_str = dstring_new (); res->strref_hash = Hash_NewTable (1021, strref_get_key, strref_free, res, pr->hashctx); + DARRAY_INIT (&res->fmt_item_blocks, 8); PR_Resources_Register (pr, "Strings", res, pr_strings_clear, pr_strings_destroy);