diff options
author | Corey Farrell <git@cfware.com> | 2017-12-29 23:59:00 -0500 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2018-01-01 19:17:15 -0500 |
commit | 5b395a7b97775f62083675f13537179150befd3f (patch) | |
tree | 466e3550e77dd543e0eb52a20d8499c6a443e081 /main/format.c | |
parent | b47882df72fbeae6ab340b21817d7f3fc4a1ba97 (diff) |
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
Diffstat (limited to 'main/format.c')
-rw-r--r-- | main/format.c | 53 |
1 files changed, 4 insertions, 49 deletions
diff --git a/main/format.c b/main/format.c index 758a7fc5e..b81a1f1d4 100644 --- a/main/format.c +++ b/main/format.c @@ -64,53 +64,8 @@ struct format_interface { /*! \brief Container for registered format interfaces */ static struct ao2_container *interfaces; -static int format_interface_hash(const void *obj, int flags) -{ - const struct format_interface *format_interface; - const char *key; - - switch (flags & OBJ_SEARCH_MASK) { - case OBJ_SEARCH_KEY: - key = obj; - return ast_str_hash(key); - case OBJ_SEARCH_OBJECT: - format_interface = obj; - return ast_str_hash(format_interface->codec); - default: - /* Hash can only work on something with a full key. */ - ast_assert(0); - return 0; - } -} - -static int format_interface_cmp(void *obj, void *arg, int flags) -{ - const struct format_interface *left = obj; - const struct format_interface *right = arg; - const char *right_key = arg; - int cmp; - - switch (flags & OBJ_SEARCH_MASK) { - case OBJ_SEARCH_OBJECT: - cmp = strcmp(left->codec, right->codec); - break; - case OBJ_SEARCH_KEY: - cmp = strcmp(left->codec, right_key); - break; - case OBJ_SEARCH_PARTIAL_KEY: - cmp = strncmp(left->codec, right_key, strlen(right_key)); - break; - default: - ast_assert(0); - cmp = 0; - break; - } - if (cmp) { - return 0; - } - - return CMP_MATCH; -} +AO2_STRING_FIELD_HASH_FN(format_interface, codec) +AO2_STRING_FIELD_CMP_FN(format_interface, codec) /*! \brief Function called when the process is shutting down */ static void format_shutdown(void) @@ -121,8 +76,8 @@ static void format_shutdown(void) int ast_format_init(void) { - interfaces = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, FORMAT_INTERFACE_BUCKETS, format_interface_hash, - format_interface_cmp); + interfaces = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, FORMAT_INTERFACE_BUCKETS, + format_interface_hash_fn, format_interface_cmp_fn); if (!interfaces) { return -1; } |