mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387209 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -993,16 +993,17 @@ static int mod_load_cmp(void *a, void *b)
|
||||
{
|
||||
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
|
||||
|
Reference in New Issue
Block a user