From 5b395a7b97775f62083675f13537179150befd3f Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Fri, 29 Dec 2017 23:59:00 -0500 Subject: core: Use macros to generate ao2_container callbacks where possible. This uses AO2_STRING_FIELD_HASH_FN and AO2_STRING_FIELD_CMP_FN where possible in the Asterisk core. This removes CMP_STOP from the result of CMP_FN callbacks for the following structure types: * ast_bucket_metadata * ast_bucket_scheme * generic_monitor_instance_list (ccss.c) * named_acl Change-Id: Ide4c1449a894bce70dea1fef664dade9b57578f1 --- main/codec.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'main/codec.c') diff --git a/main/codec.c b/main/codec.c index d0e63682b..05cee4ab6 100644 --- a/main/codec.c +++ b/main/codec.c @@ -75,24 +75,7 @@ struct internal_ast_codec { int __ast_codec_register_with_format(struct ast_codec *codec, const char *format_name, struct ast_module *mod); -static int codec_hash(const void *obj, int flags) -{ - const struct ast_codec *codec; - const char *key; - - switch (flags & OBJ_SEARCH_MASK) { - case OBJ_SEARCH_KEY: - key = obj; - return ast_str_hash(key); - case OBJ_SEARCH_OBJECT: - codec = obj; - return ast_str_hash(codec->name); - default: - /* Hash can only work on something with a full key. */ - ast_assert(0); - return 0; - } -} +AO2_STRING_FIELD_HASH_FN(ast_codec, name) static int codec_cmp(void *obj, void *arg, int flags) { @@ -267,7 +250,8 @@ static void codec_shutdown(void) int ast_codec_init(void) { - codecs = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, CODEC_BUCKETS, codec_hash, codec_cmp); + codecs = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, CODEC_BUCKETS, + ast_codec_hash_fn, codec_cmp); if (!codecs) { return -1; } -- cgit v1.2.3