static char *cli_prompt(EditLine *el)
{
- char prompt[80];
+ static char prompt[80];
if (remotehostname)
snprintf(prompt, sizeof(prompt), ASTERISK_PROMPT2, remotehostname);
else
snprintf(prompt, sizeof(prompt), ASTERISK_PROMPT);
- return strdup(prompt);
+ return(prompt);
}
static char **ast_el_strtoarr(char *buf)
if (nummatches == 1) {
/* Found an exact match */
- el_insertstr(el, strdup(" "));
+ el_insertstr(el, " ");
retval = CC_REFRESH;
} else {
/* Must be more than one match */
ast_cli_display_match_list(matches, nummatches, maxlen);
retval = CC_REDISPLAY;
} else {
- el_insertstr(el,strdup(" "));
+ el_insertstr(el," ");
retval = CC_REFRESH;
}
}
-
+ free(matches);
}
return (char *)retval;
printf("command matchesarray for '%s' %s got '%s'\n", argv[2], argv[3], matches[x]);
#endif
len += sprintf( buf + len, "%s ", matches[x]);
+ free(matches[x]);
+ matches[x] = NULL;
}
+ free(matches);
}
#if 0
printf("array for '%s' %s got '%s'\n", argv[2], argv[3], buf);
int ast_cli_generatornummatches(char *text, char *word)
{
int matches = 0, i = 0;
- char *buf, *oldbuf;
+ char *buf, *oldbuf = NULL;
while ( (buf = ast_cli_generator(text, word, i)) ) {
- if (++i > 1 && strcmp(buf,oldbuf) == 0)
+ if (++i > 1 && strcmp(buf,oldbuf) == 0) {
+ free(buf);
continue;
+ }
+ if (oldbuf)
+ free(oldbuf);
oldbuf = buf;
matches++;
}
if (res) {
if (lock)
ast_pthread_mutex_unlock(&clilock);
+ free(dup);
return res ? strdup(res) : NULL;
}
}