[asterisk-commits] rmudgett: trunk r387209 - /trunk/main/loader.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed May 1 15:35:27 CDT 2013
Author: rmudgett
Date: Wed May 1 15:35:25 2013
New Revision: 387209
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387209
Log:
Make mod_load_cmp() not as klunky.
There is a reason the heap comparison functions like qsort(), and other
comparison functions specify <0, >0, and =0 for the return values.
Modified:
trunk/main/loader.c
Modified: trunk/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/loader.c?view=diff&rev=387209&r1=387208&r2=387209
==============================================================================
--- trunk/main/loader.c (original)
+++ trunk/main/loader.c Wed May 1 15:35:25 2013
@@ -993,16 +993,17 @@
{
struct ast_module *a_mod = (struct ast_module *) a;
struct ast_module *b_mod = (struct ast_module *) b;
- int res = -1;
- /* if load_pri is not set, default is 128. Lower is better*/
- unsigned char a_pri = ast_test_flag(a_mod->info, AST_MODFLAG_LOAD_ORDER) ? a_mod->info->load_pri : 128;
- unsigned char b_pri = ast_test_flag(b_mod->info, AST_MODFLAG_LOAD_ORDER) ? b_mod->info->load_pri : 128;
- if (a_pri == b_pri) {
- res = 0;
- } else if (a_pri < b_pri) {
- res = 1;
- }
- return res;
+ /* if load_pri is not set, default is 128. Lower is better */
+ int a_pri = ast_test_flag(a_mod->info, AST_MODFLAG_LOAD_ORDER) ? a_mod->info->load_pri : 128;
+ int b_pri = ast_test_flag(b_mod->info, AST_MODFLAG_LOAD_ORDER) ? b_mod->info->load_pri : 128;
+
+ /*
+ * Returns comparison values for a min-heap
+ * <0 a_pri > b_pri
+ * =0 a_pri == b_pri
+ * >0 a_pri < b_pri
+ */
+ return b_pri - a_pri;
}
/*! loads modules in order by load_pri, updates mod_count
More information about the asterisk-commits
mailing list