summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2017-01-26 18:46:19 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-01-26 18:46:19 -0600
commitcac5ee2517cc7a4bcdf45af5227716f7e55500b1 (patch)
treefc970fca81df9c06d515e64a1e68e202a6933be0 /main
parent23e5fd709ae0aba510f4a0724f85775d47652226 (diff)
parent1d890874f39a5a81b20da44358143ed9b54ab0fe (diff)
Merge "ari: Implement 'debug all' and request/response logging" into 14
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 e62eb9aad..feb67ecc6 100644
--- a/main/strings.c
+++ b/main/strings.c
@@ -186,15 +186,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)