From: Tilghman Lesher Date: Fri, 23 Dec 2005 22:47:26 +0000 (+0000) Subject: Alphabetize the functions list X-Git-Tag: 1.4.0-beta1~3144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c66748df1c5eaba16f9ff5fbba75918ffcfa3405;p=thirdparty%2Fasterisk.git Alphabetize the functions list git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7615 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/pbx.c b/pbx.c index 05315495f0..82b49a2461 100644 --- a/pbx.c +++ b/pbx.c @@ -1275,6 +1275,9 @@ int ast_custom_function_unregister(struct ast_custom_function *acf) int ast_custom_function_register(struct ast_custom_function *acf) { + struct ast_custom_function *cur, *last = NULL; + int found = 0; + if (!acf) return -1; @@ -1290,8 +1293,29 @@ int ast_custom_function_register(struct ast_custom_function *acf) return -1; } - acf->next = acf_root; - acf_root = acf; + for (cur = acf_root; cur; cur = cur->next) { + if (strcmp(acf->name, cur->name) < 0) { + found = 1; + if (last) { + acf->next = cur; + last->next = acf; + } else { + acf->next = acf_root; + acf_root = acf; + } + break; + } + last = cur; + } + + /* Wasn't before anything else, put it at the end */ + if (!found) { + if (last) + last->next = acf; + else + acf_root = acf; + acf->next = NULL; + } ast_mutex_unlock(&acflock);