From 634599d04d02252fd0457a19a06e8965bcdaed04 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Sun, 8 Jan 2006 23:57:07 +0000 Subject: 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 --- pjsip/src/pjsip/sip_endpoint.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pjsip') 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; imodules); ++i) { if (endpt->modules[i] == NULL) -- cgit v1.2.3