<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8052">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">loader: Use ast_cli_completion_add for 'module load' completion.<br><br>This should address potential performance issues with this completion<br>function.<br><br>Change-Id: I8bf51ffaa7ef1606f3bd1b5bb13f1905d72c6134<br>---<br>M main/loader.c<br>1 file changed, 8 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/52/8052/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/loader.c b/main/loader.c<br>index 6119d63..f4e5f5a 100644<br>--- a/main/loader.c<br>+++ b/main/loader.c<br>@@ -58,6 +58,7 @@<br> #include "asterisk/app.h"<br> #include "asterisk/test.h"<br> #include "asterisk/sounds_index.h"<br>+#include "asterisk/cli.h"<br> <br> #include <dlfcn.h><br> <br>@@ -771,12 +772,10 @@<br>        }<br> }<br> <br>-static char *module_load_helper(const char *word, int state)<br>+static void module_load_helper(const char *word)<br> {<br>        struct ast_module *mod;<br>-      int which = 0;<br>        char *name;<br>-  char *ret = NULL;<br>     char *editline_ret;<br>   char fullpath[PATH_MAX];<br>      int idx = 0;<br>@@ -804,14 +803,14 @@<br>    * The only way to avoid this would be to make a copy of the function<br>          * that skips matches found in the running_modules vector.<br>     */<br>-  while (!ret && (name = editline_ret = filename_completion_function(fullpath, idx++))) {<br>+      while ((name = editline_ret = filename_completion_function(fullpath, idx++))) {<br>               if (word[0] != '/') {<br>                         name += (strlen(ast_config_AST_MODULE_DIR) + 1);<br>              }<br> <br>          /* Don't list files that are already loaded! */<br>-          if (!AST_VECTOR_GET_CMP(&running_modules, name, !strcasecmp) && ++which > state) {<br>-                    ret = ast_strdup(name);<br>+              if (!AST_VECTOR_GET_CMP(&running_modules, name, !strcasecmp)) {<br>+                  ast_cli_completion_add(ast_strdup(name));<br>             }<br> <br>          ast_std_free(editline_ret);<br>@@ -820,8 +819,6 @@<br>      /* Do not clean-up the elements, they belong to module_list. */<br>       AST_VECTOR_FREE(&running_modules);<br>        AST_DLLIST_UNLOCK(&module_list);<br>-<br>-      return ret;<br> }<br> <br> char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int _type)<br>@@ -837,7 +834,9 @@<br>        }<br> <br>  if (type == AST_MODULE_HELPER_LOAD) {<br>-                return module_load_helper(word, state);<br>+              module_load_helper(word);<br>+<br>+         return NULL;<br>  }<br> <br>  if (type == AST_MODULE_HELPER_RELOAD) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8052">change 8052</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8052"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I8bf51ffaa7ef1606f3bd1b5bb13f1905d72c6134 </div>
<div style="display:none"> Gerrit-Change-Number: 8052 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>