summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2013-06-22 14:26:25 +0000
committerJoshua Colp <jcolp@digium.com>2013-06-22 14:26:25 +0000
commita330d0867e3155e34ecbfd23a84fe6e7ebf51469 (patch)
treed19cbb217482b0dc2952afe2495d59b868d1ff82 /res
parent77002bc377f19ea11e60732c486b6ef371688773 (diff)
Make sorcery details opaque and add extended fields.
Sorcery specific object information is now opaque and allocated with the object. This means that modules do not need to be recompiled if the sorcery specific part is changed. It also means that sorcery can store additional information on objects and ensure it is freed or the reference count decreased when the object goes away. To facilitate the above a generic sorcery allocator function has been added which also ensures that allocated objects do not have a lock. Extended fields have been added thanks to all of the above which allows specific fields to be marked as extended, and thus simply stored as-is within the object. Type safety is *NOT* enforced on these fields. A consumer of them has to query and ultimately perform their own safety check. What does this mean? Extra modules can extend already defined structures without having to modify them. Tests have also been included to verify extended field functionality. Review: https://reviewboard.asterisk.org/r/2585/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392586 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r--res/res_sip/config_auth.c2
-rw-r--r--res/res_sip/config_domain_aliases.c2
-rw-r--r--res/res_sip/config_transport.c2
-rw-r--r--res/res_sip/location.c4
-rw-r--r--res/res_sip/sip_configuration.c4
-rw-r--r--res/res_sip/sip_options.c3
6 files changed, 8 insertions, 9 deletions
diff --git a/res/res_sip/config_auth.c b/res/res_sip/config_auth.c
index 9881dd8c6..47ff42deb 100644
--- a/res/res_sip/config_auth.c
+++ b/res/res_sip/config_auth.c
@@ -32,7 +32,7 @@ static void auth_destroy(void *obj)
static void *auth_alloc(const char *name)
{
- struct ast_sip_auth *auth = ao2_alloc(sizeof(*auth), auth_destroy);
+ struct ast_sip_auth *auth = ast_sorcery_generic_alloc(sizeof(*auth), auth_destroy);
if (!auth) {
return NULL;
diff --git a/res/res_sip/config_domain_aliases.c b/res/res_sip/config_domain_aliases.c
index 86b4636ea..90cd82f94 100644
--- a/res/res_sip/config_domain_aliases.c
+++ b/res/res_sip/config_domain_aliases.c
@@ -33,7 +33,7 @@ static void domain_alias_destroy(void *obj)
static void *domain_alias_alloc(const char *name)
{
- struct ast_sip_domain_alias *alias = ao2_alloc(sizeof(*alias), domain_alias_destroy);
+ struct ast_sip_domain_alias *alias = ast_sorcery_generic_alloc(sizeof(*alias), domain_alias_destroy);
if (!alias) {
return NULL;
diff --git a/res/res_sip/config_transport.c b/res/res_sip/config_transport.c
index 1d60274b7..30c1362a5 100644
--- a/res/res_sip/config_transport.c
+++ b/res/res_sip/config_transport.c
@@ -62,7 +62,7 @@ static void transport_destroy(void *obj)
/*! \brief Allocator for transport */
static void *transport_alloc(const char *name)
{
- struct ast_sip_transport *transport = ao2_alloc(sizeof(*transport), transport_destroy);
+ struct ast_sip_transport *transport = ast_sorcery_generic_alloc(sizeof(*transport), transport_destroy);
if (!transport) {
return NULL;
diff --git a/res/res_sip/location.c b/res/res_sip/location.c
index d0b0a28c9..bc1b5211e 100644
--- a/res/res_sip/location.c
+++ b/res/res_sip/location.c
@@ -41,7 +41,7 @@ static void aor_destroy(void *obj)
/*! \brief Allocator for AOR */
static void *aor_alloc(const char *name)
{
- struct ast_sip_aor *aor = ao2_alloc_options(sizeof(struct ast_sip_aor), aor_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
+ struct ast_sip_aor *aor = ast_sorcery_generic_alloc(sizeof(struct ast_sip_aor), aor_destroy);
if (!aor) {
return NULL;
}
@@ -60,7 +60,7 @@ static void contact_destroy(void *obj)
/*! \brief Allocator for contact */
static void *contact_alloc(const char *name)
{
- struct ast_sip_contact *contact = ao2_alloc_options(sizeof(*contact), contact_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
+ struct ast_sip_contact *contact = ast_sorcery_generic_alloc(sizeof(*contact), contact_destroy);
if (!contact) {
return NULL;
diff --git a/res/res_sip/sip_configuration.c b/res/res_sip/sip_configuration.c
index 5864bdeec..49c2da28c 100644
--- a/res/res_sip/sip_configuration.c
+++ b/res/res_sip/sip_configuration.c
@@ -515,7 +515,7 @@ static int named_groups_handler(const struct aco_option *opt,
static void *sip_nat_hook_alloc(const char *name)
{
- return ao2_alloc(sizeof(struct ast_sip_nat_hook), NULL);
+ return ast_sorcery_generic_alloc(sizeof(struct ast_sip_nat_hook), NULL);
}
/*! \brief Destructor function for persistent endpoint information */
@@ -722,7 +722,7 @@ static void endpoint_destructor(void* obj)
void *ast_sip_endpoint_alloc(const char *name)
{
- struct ast_sip_endpoint *endpoint = ao2_alloc(sizeof(*endpoint), endpoint_destructor);
+ struct ast_sip_endpoint *endpoint = ast_sorcery_generic_alloc(sizeof(*endpoint), endpoint_destructor);
if (!endpoint) {
return NULL;
}
diff --git a/res/res_sip/sip_options.c b/res/res_sip/sip_options.c
index 4c8a9f6a7..4f21238b7 100644
--- a/res/res_sip/sip_options.c
+++ b/res/res_sip/sip_options.c
@@ -42,8 +42,7 @@ static int qualify_contact(struct ast_sip_contact *contact);
*/
static void *contact_status_alloc(const char *name)
{
- struct ast_sip_contact_status *status = ao2_alloc_options(
- sizeof(*status), NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
+ struct ast_sip_contact_status *status = ast_sorcery_generic_alloc(sizeof(*status), NULL);
if (!status) {
ast_log(LOG_ERROR, "Unable to allocate ast_sip_contact_status\n");