summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-01-08 23:57:07 +0000
committerBenny Prijono <bennylp@teluu.com>2006-01-08 23:57:07 +0000
commit634599d04d02252fd0457a19a06e8965bcdaed04 (patch)
tree5405a6142366fa3178f0698e3af3d98dec0fef3e /pjsip
parentf7bc85f6f5064c4dabaf5ef090d634234641eef2 (diff)
Do not allow modules with the same name to be registered
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@116 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsip/sip_endpoint.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c
index ea203415..71e7cff8 100644
--- a/pjsip/src/pjsip/sip_endpoint.c
+++ b/pjsip/src/pjsip/sip_endpoint.c
@@ -125,6 +125,12 @@ static void pool_callback( pj_pool_t *pool, pj_size_t size )
}
+/* Compare module name, used for searching module based on name. */
+static int cmp_mod_name(void *name, const pjsip_module *mod)
+{
+ return pj_stricmp(name, &mod->name);
+}
+
/*
* Register new module to the endpoint.
* The endpoint will then call the load and start function in the module to
@@ -144,6 +150,11 @@ PJ_DEF(pj_status_t) pjsip_endpt_register_module( pjsip_endpoint *endpt,
PJ_ASSERT_ON_FAIL( pj_list_find_node(&endpt->module_list, mod) == NULL,
{status = PJ_EEXISTS; goto on_return;});
+ /* Make sure that no module with the same name has been registered. */
+ PJ_ASSERT_ON_FAIL( pj_list_search(&endpt->module_list, &mod->name,
+ &cmp_mod_name)==NULL,
+ {status = PJ_EEXISTS; goto on_return; });
+
/* Find unused ID for this module. */
for (i=0; i<PJ_ARRAY_SIZE(endpt->modules); ++i) {
if (endpt->modules[i] == NULL)