From 83032b1aa3c3e5910c5cfd3e0ea1d25827f56475 Mon Sep 17 00:00:00 2001 From: TingPing Date: Sun, 28 Dec 2014 06:37:25 -0500 Subject: Use glib for all allocations - Removes need to check for malloc failure - Removes need for NULL checks on free - Adds checks for integer overflows - Removes some extra memset calls - Removes chance of mixing libc and glib malloc/free --- src/common/history.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/common/history.c') diff --git a/src/common/history.c b/src/common/history.c index 1acd3327..34924568 100644 --- a/src/common/history.c +++ b/src/common/history.c @@ -18,14 +18,14 @@ #include #include +#include #include "history.h" void history_add (struct history *his, char *text) { - if (his->lines[his->realpos]) - free (his->lines[his->realpos]); - his->lines[his->realpos] = strdup (text); + g_free (his->lines[his->realpos]); + his->lines[his->realpos] = g_strdup (text); his->realpos++; if (his->realpos == HISTORY_SIZE) his->realpos = 0; @@ -40,7 +40,7 @@ history_free (struct history *his) { if (his->lines[i]) { - free (his->lines[i]); + g_free (his->lines[i]); his->lines[i] = 0; } } -- cgit 1.4.1