about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-14 22:09:31 +0000
committerJames Booth <boothj5@gmail.com>2013-01-14 22:09:31 +0000
commit87c3107847cb1317af7cb00b62632e847e765fdf (patch)
tree4d0a03bee98d35871c0b5415c8e1814b1b0351fd /src
parent6abbe62710b553fa67282746a921afdeb31e86e1 (diff)
downloadprofani-tty-87c3107847cb1317af7cb00b62632e847e765fdf.tar.gz
Used strdup in prof_autocomplete
Diffstat (limited to 'src')
-rw-r--r--src/prof_autocomplete.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/prof_autocomplete.c b/src/prof_autocomplete.c
index cd69d664..75e82166 100644
--- a/src/prof_autocomplete.c
+++ b/src/prof_autocomplete.c
@@ -195,18 +195,13 @@ _search_from(PAutocomplete ac, GSList *curr)
     while(curr) {
 
         // match found
-        if (strncmp(curr->data,
-                ac->search_str,
-                strlen(ac->search_str)) == 0) {
-            gchar *result =
-                (gchar *) malloc((strlen(curr->data) + 1) * sizeof(gchar));
+        if (strncmp(curr->data, ac->search_str, strlen(ac->search_str)) == 0) {
 
             // set pointer to last found
             ac->last_found = curr;
 
             // return the string, must be free'd by caller
-            strcpy(result, curr->data);
-            return result;
+            return strdup(curr->data);
         }
 
         curr = g_slist_next(curr);