[asterisk-commits] trunk - r7615 /trunk/pbx.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Dec 23 16:47:26 CST 2005
Author: tilghman
Date: Fri Dec 23 16:47:26 2005
New Revision: 7615
URL: http://svn.digium.com/view/asterisk?rev=7615&view=rev
Log:
Alphabetize the functions list
Modified:
trunk/pbx.c
Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=7615&r1=7614&r2=7615&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Fri Dec 23 16:47:26 2005
@@ -1275,6 +1275,9 @@
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 @@
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);
More information about the asterisk-commits
mailing list