aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-10-13 08:20:35 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2016-10-13 19:51:43 +0200
commit9ef5fe2191c5d1d857bc4fe828c15268ba8caa90 (patch)
treea02c31a337f0b189ea0cab7141901ee455ccc3d9 /src
parentda6334cf385ff064a8296e8c0d0e080fa2014eaa (diff)
downloadcalcurse-9ef5fe2191c5d1d857bc4fe828c15268ba8caa90.tar.gz
calcurse-9ef5fe2191c5d1d857bc4fe828c15268ba8caa90.zip
Always use memory management wrappers
Use mem_*() wrappers instead of directly accessing libc functions when allocating/deallocating memory. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/args.c4
-rw-r--r--src/custom.c2
-rw-r--r--src/help.c4
-rw-r--r--src/io.c4
-rw-r--r--src/listbox.c8
-rw-r--r--src/note.c10
-rw-r--r--src/vector.c4
7 files changed, 18 insertions, 18 deletions
diff --git a/src/args.c b/src/args.c
index 3834f4a..afb4bfc 100644
--- a/src/args.c
+++ b/src/args.c
@@ -317,7 +317,7 @@ static time_t parse_datetimearg(const char *str)
static int parse_daterange(const char *str, time_t *date_from, time_t *date_to)
{
int ret = 0;
- char *s = xstrdup(str);
+ char *s = mem_strdup(str);
char *p = strchr(s, ',');
if (!p)
@@ -344,7 +344,7 @@ static int parse_daterange(const char *str, time_t *date_from, time_t *date_to)
ret = 1;
cleanup:
- free(s);
+ mem_free(s);
return ret;
}
diff --git a/src/custom.c b/src/custom.c
index 4e232e4..ef285e9 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -754,7 +754,7 @@ static void general_option_edit(int i)
break;
}
- free(buf);
+ mem_free(buf);
}
/* General configuration. */
diff --git a/src/help.c b/src/help.c
index 2de01cd..5cfe6d0 100644
--- a/src/help.c
+++ b/src/help.c
@@ -45,7 +45,7 @@ static int find_basedir(const char *locale_info[], unsigned n, char **basedir)
for (i = 0; i < n; i++) {
if (!locale_info[i])
continue;
- locale = strdup(locale_info[i]);
+ locale = mem_strdup(locale_info[i]);
asprintf(basedir, "%s/%s", DOCDIR, locale);
if (io_dir_exists(*basedir)) {
@@ -79,7 +79,7 @@ static int find_basedir(const char *locale_info[], unsigned n, char **basedir)
cleanup:
if (locale)
- free(locale);
+ mem_free(locale);
return ret;
}
diff --git a/src/io.c b/src/io.c
index e0a8502..2dd5b34 100644
--- a/src/io.c
+++ b/src/io.c
@@ -821,8 +821,8 @@ void io_reload_data(void)
wins_launch_external(arg_todo);
}
- xfree(path_apts_backup);
- xfree(path_todo_backup);
+ mem_free(path_apts_backup);
+ mem_free(path_todo_backup);
/*
* We do not directly write to the data files here;
diff --git a/src/listbox.c b/src/listbox.c
index 333ddeb..a620adb 100644
--- a/src/listbox.c
+++ b/src/listbox.c
@@ -56,8 +56,8 @@ void listbox_delete(struct listbox *lb)
{
EXIT_IF(lb == NULL, "null pointer");
wins_scrollwin_delete(&(lb->sw));
- free(lb->type);
- free(lb->ch);
+ mem_free(lb->type);
+ mem_free(lb->ch);
}
void listbox_resize(struct listbox *lb, int y, int x, int h, int w)
@@ -95,8 +95,8 @@ void listbox_load_items(struct listbox *lb, int item_count)
return;
}
- free(lb->type);
- free(lb->ch);
+ mem_free(lb->type);
+ mem_free(lb->ch);
lb->type = mem_malloc(item_count * sizeof(unsigned));
lb->ch = mem_malloc((item_count + 1) * sizeof(unsigned));
for (i = 0, ch = 0; i < item_count; i++) {
diff --git a/src/note.c b/src/note.c
index 4b274cd..0008a5f 100644
--- a/src/note.c
+++ b/src/note.c
@@ -201,7 +201,7 @@ void note_gc(void)
struct apoint *apt = LLIST_GET_DATA(i);
if (apt->note) {
tmph.hash = apt->note;
- free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
+ mem_free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
}
}
@@ -209,7 +209,7 @@ void note_gc(void)
struct event *ev = LLIST_GET_DATA(i);
if (ev->note) {
tmph.hash = ev->note;
- free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
+ mem_free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
}
}
@@ -217,7 +217,7 @@ void note_gc(void)
struct recur_apoint *rapt = LLIST_GET_DATA(i);
if (rapt->note) {
tmph.hash = rapt->note;
- free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
+ mem_free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
}
}
@@ -225,7 +225,7 @@ void note_gc(void)
struct recur_event *rev = LLIST_GET_DATA(i);
if (rev->note) {
tmph.hash = rev->note;
- free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
+ mem_free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
}
}
@@ -233,7 +233,7 @@ void note_gc(void)
struct todo *todo = LLIST_GET_DATA(i);
if (todo->note) {
tmph.hash = todo->note;
- free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
+ mem_free(HTABLE_REMOVE(htp, &gc_htable, &tmph));
}
}
diff --git a/src/vector.c b/src/vector.c
index 10294a7..ef59f8f 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -53,7 +53,7 @@ void vector_free(vector_t *v)
{
v->count = 0;
v->size = 0;
- free(v->data);
+ mem_free(v->data);
v->data = NULL;
}
@@ -100,7 +100,7 @@ void vector_add(vector_t *v, void *data)
{
if (v->count >= v->size) {
v->size *= 2;
- v->data = realloc(v->data, v->size * sizeof(void *));
+ v->data = mem_realloc(v->data, v->size, sizeof(void *));
}
v->data[v->count] = data;