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>
This commit is contained in:
Lukas Fleischer 2016-10-13 08:20:35 +02:00
parent da6334cf38
commit 9ef5fe2191
7 changed files with 18 additions and 18 deletions

View File

@ -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;
}

View File

@ -754,7 +754,7 @@ static void general_option_edit(int i)
break;
}
free(buf);
mem_free(buf);
}
/* General configuration. */

View File

@ -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;
}

View File

@ -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;

View File

@ -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++) {

View File

@ -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));
}
}

View File

@ -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;