From: Alan T. DeKok Date: Sun, 4 Feb 2024 15:15:35 +0000 (-0500) Subject: clean up autofree X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f937f361817f176925865ad98fa4eb367d6dfbc;p=thirdparty%2Ffreeradius-server.git clean up autofree The only remaining errors are: test.unit.dns, which fails to clean up the DNS dictionaries. All of the other protocols are fine, so there's some extra magic here. test.keywords: fr_dict_free() is asked to remove a dependency which doesn't exist. That _should_ be an assertion, but for now it's a recoverable error which lets other people get work done. --- diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index a1bbd41cf9d..622ba05c95d 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -3327,9 +3327,10 @@ static int dict_autoref_free(fr_dict_t *dict) return -1; } + /* + * Free the dictionary. It will call proto->free() if there's nothing more to do. + */ for (i = 0; i < talloc_array_length(refd_list); i++) { - if (refd_list[i]->proto->free) refd_list[i]->proto->free(); - if (fr_dict_free(&refd_list[i], dict->root->name) < 0) { fr_strerror_printf("failed freeing autoloaded protocol %s", refd_list[i]->root->name); return -1; @@ -3397,8 +3398,6 @@ static int _dict_free(fr_dict_t *dict) return -1; } -// if (dict_autoref_free(dict) < 0) return -1; - /* * Free the hash tables with free functions first * so that the things the hash tables reference @@ -3925,7 +3924,7 @@ static int _dict_global_free(fr_dict_gctx_t *gctx) dict = fr_hash_table_iter_next(gctx->protocol_by_name, &iter)) { (void)talloc_get_type_abort(dict, fr_dict_t); -// if (dict_autoref_free(dict) < 0) return -1; + if (dict_autoref_free(dict) < 0) return -1; } for (dict = fr_hash_table_iter_init(gctx->protocol_by_name, &iter);