diff options
author | Joshua Colp <jcolp@digium.com> | 2017-11-20 17:27:07 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-11-20 17:27:07 -0600 |
commit | a881c52c7848d5ac36a0882a5e03e09c3b17cce2 (patch) | |
tree | 05ba9b298b9e69767f13f5a1f328725869fdce1d /res | |
parent | 67f5875969004a1b6c3f8226c195b39f3cd26143 (diff) | |
parent | 4b5ccddd096bb093ec0cca576dc8dc7259f682fc (diff) |
Merge "res_pjsip: Use sorcery prefix operation for contact lookup" into 15
Diffstat (limited to 'res')
-rw-r--r-- | res/res_pjsip/location.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c index 0d7b3da31..299fdb722 100644 --- a/res/res_pjsip/location.c +++ b/res/res_pjsip/location.c @@ -82,16 +82,17 @@ static void aor_deleted_observer(const void *object) { const struct ast_sip_aor *aor = object; const char *aor_id = ast_sorcery_object_get_id(object); - /* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */ - char regex[strlen(aor_id) + 4]; + /* Give enough space for ;@ at the end, since that is our object naming scheme */ + size_t prefix_len = strlen(aor_id) + sizeof(";@") - 1; + char prefix[prefix_len + 1]; struct ao2_container *contacts; if (aor->permanent_contacts) { ao2_callback(aor->permanent_contacts, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, destroy_contact, NULL); } - snprintf(regex, sizeof(regex), "^%s;@", aor_id); - if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) { + sprintf(prefix, "%s;@", aor_id); /* Safe */ + if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) { return; } /* Destroy any contacts that may still exist that were made for this AoR */ @@ -223,13 +224,13 @@ struct ao2_container *ast_sip_location_retrieve_aor_contacts_nolock(const struct struct ao2_container *ast_sip_location_retrieve_aor_contacts_nolock_filtered(const struct ast_sip_aor *aor, unsigned int flags) { - /* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */ - char regex[strlen(ast_sorcery_object_get_id(aor)) + 4]; + /* Give enough space for ;@ at the end, since that is our object naming scheme */ + size_t prefix_len = strlen(ast_sorcery_object_get_id(aor)) + sizeof(";@") - 1; + char prefix[prefix_len + 1]; struct ao2_container *contacts; - snprintf(regex, sizeof(regex), "^%s;@", ast_sorcery_object_get_id(aor)); - - if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) { + sprintf(prefix, "%s;@", ast_sorcery_object_get_id(aor)); /* Safe */ + if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) { return NULL; } |