git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@6636
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
int matches = 0, i = 0;
char *buf = NULL, *oldbuf = NULL;
- while ( (buf = ast_cli_generator(text, word, i)) ) {
- if (++i > 1 && strcmp(buf,oldbuf) == 0) {
- continue;
- }
+ while ( (buf = ast_cli_generator(text, word, i++)) ) {
+ if (!oldbuf || strcmp(buf,oldbuf))
+ matches++;
+ if (oldbuf)
+ free(oldbuf);
oldbuf = buf;
- matches++;
}
-
+ if (oldbuf)
+ free(oldbuf);
return matches;
}