about summary refs log tree commit diff stats
path: root/src/tools/autocomplete.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-08-04 17:20:46 +0100
committerJames Booth <boothj5@gmail.com>2013-08-04 17:20:46 +0100
commit3588a9d7761669f6d1c6776a07cc0555afd4b084 (patch)
tree7a1d204a8d2fcc4f3b0ac7f5278b978446c54ad5 /src/tools/autocomplete.c
parent87c627710906171b3696e65fac985bd50c43c6f3 (diff)
parent20dff5fe2f0251d39a1667b547a49cef3b115899 (diff)
downloadprofani-tty-3588a9d7761669f6d1c6776a07cc0555afd4b084.tar.gz
Merge remote-tracking branch 'dmitry/nextdev-patches' into nextdev
Diffstat (limited to 'src/tools/autocomplete.c')
-rw-r--r--src/tools/autocomplete.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index 0c56cac7..5c70f874 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "common.h"
 #include "tools/autocomplete.h"
 #include "tools/parser.h"
 
@@ -59,10 +60,7 @@ void
 autocomplete_reset(Autocomplete ac)
 {
     ac->last_found = NULL;
-    if (ac->search_str != NULL) {
-        free(ac->search_str);
-        ac->search_str = NULL;
-    }
+    FREE_SET_NULL(ac->search_str);
 }
 
 void
@@ -220,7 +218,7 @@ autocomplete_param_with_func(char *input, int *size, char *command,
         inp_cpy[(*size) - len] = '\0';
         found = func(inp_cpy);
         if (found != NULL) {
-            auto_msg = (char *) malloc((len + (strlen(found) + 1)) * sizeof(char));
+            auto_msg = (char *) malloc(len + strlen(found) + 1);
             strcpy(auto_msg, command_cpy);
             strcat(auto_msg, found);
             free(found);
@@ -249,7 +247,7 @@ autocomplete_param_with_ac(char *input, int *size, char *command,
         inp_cpy[(*size) - len] = '\0';
         found = autocomplete_complete(ac, inp_cpy);
         if (found != NULL) {
-            auto_msg = (char *) malloc((len + (strlen(found) + 1)) * sizeof(char));
+            auto_msg = (char *) malloc(len + strlen(found) + 1);
             strcpy(auto_msg, command_cpy);
             strcat(auto_msg, found);
             free(found);