aboutsummaryrefslogtreecommitdiffstats
path: root/pbx.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-23 22:47:26 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-23 22:47:26 +0000
commit1b08c58c312c91b4ea68e2800ff91ba2d1bfb089 (patch)
treebb909c48643680f66b6a7b87b3d4ff02816ef7ff /pbx.c
parente19e560da2cd5e8bbfe03afc6bb360ac764357d1 (diff)
Alphabetize the functions list
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7615 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx.c')
-rw-r--r--pbx.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/pbx.c b/pbx.c
index 05315495f..82b49a246 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);