diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-10-13 08:20:35 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-10-13 19:51:43 +0200 |
commit | 9ef5fe2191c5d1d857bc4fe828c15268ba8caa90 (patch) | |
tree | a02c31a337f0b189ea0cab7141901ee455ccc3d9 /src | |
parent | da6334cf385ff064a8296e8c0d0e080fa2014eaa (diff) | |
download | 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.c | 4 | ||||
-rw-r--r-- | src/custom.c | 2 | ||||
-rw-r--r-- | src/help.c | 4 | ||||
-rw-r--r-- | src/io.c | 4 | ||||
-rw-r--r-- | src/listbox.c | 8 | ||||
-rw-r--r-- | src/note.c | 10 | ||||
-rw-r--r-- | src/vector.c | 4 |
7 files changed, 18 insertions, 18 deletions
@@ -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. */ @@ -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; } @@ -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++) { @@ -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; |