summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2017-01-26 17:06:40 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-01-26 17:06:40 -0600
commit0ad6d2b3cf56610e36af30baa0ac88f5d29da78c (patch)
treef4dd5a245ac2bf173ffed83095c95a6669a4df6e /main
parent071aa069e6a50a08208f8802115b788e8ddc8303 (diff)
parent66916067236dc2f5cf54fadee33a5203d8716148 (diff)
Merge "ari: Implement 'debug all' and request/response logging"
Diffstat (limited to 'main')
-rw-r--r--main/strings.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/main/strings.c b/main/strings.c
index b8f1ccbfd..d29da67bc 100644
--- a/main/strings.c
+++ b/main/strings.c
@@ -184,15 +184,32 @@ static int str_hash(const void *obj, const int flags)
return ast_str_hash(obj);
}
+static int str_sort(const void *lhs, const void *rhs, int flags)
+{
+ if ((flags & OBJ_SEARCH_MASK) == OBJ_SEARCH_PARTIAL_KEY) {
+ return strncmp(lhs, rhs, strlen(rhs));
+ } else {
+ return strcmp(lhs, rhs);
+ }
+}
+
static int str_cmp(void *lhs, void *rhs, int flags)
{
- return strcmp(lhs, rhs) ? 0 : CMP_MATCH;
+ int cmp = 0;
+
+ if ((flags & OBJ_SEARCH_MASK) == OBJ_SEARCH_PARTIAL_KEY) {
+ cmp = strncmp(lhs, rhs, strlen(rhs));
+ } else {
+ cmp = strcmp(lhs, rhs);
+ }
+
+ return cmp ? 0 : CMP_MATCH;
}
//struct ao2_container *ast_str_container_alloc_options(enum ao2_container_opts opts, int buckets)
struct ao2_container *ast_str_container_alloc_options(enum ao2_alloc_opts opts, int buckets)
{
- return ao2_container_alloc_options(opts, buckets, str_hash, str_cmp);
+ return ao2_container_alloc_hash(opts, 0, buckets, str_hash, str_sort, str_cmp);
}
int ast_str_container_add(struct ao2_container *str_container, const char *add)