diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-04-12 11:37:22 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-04-13 08:22:44 -0300 |
commit | 34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b (patch) | |
tree | 3342c6d4a1cc54bbadb6018725410117885b3517 /src/nvim/api/buffer.c | |
parent | ba10e311bddab18e38b1b706e232f804c2da9174 (diff) | |
download | rneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.tar.gz rneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.tar.bz2 rneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.zip |
memory: Add `free` wrapper and refactor project to use it
We already use wrappers for allocation, the new `xfree` function is the
equivalent for deallocation and provides a way to fully replace the malloc
implementation used by Neovim.
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r-- | src/nvim/api/buffer.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 5bd48fc19f..c9ada8dfc0 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -58,7 +58,7 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err) rv = slice.items[0].data.string; } - free(slice.items); + xfree(slice.items); return rv; } @@ -144,10 +144,10 @@ ArrayOf(String) buffer_get_line_slice(Buffer buffer, end: if (err->set) { for (size_t i = 0; i < rv.size; i++) { - free(rv.items[i].data.string.data); + xfree(rv.items[i].data.string.data); } - free(rv.items); + xfree(rv.items); rv.items = NULL; } @@ -280,7 +280,7 @@ void buffer_set_line_slice(Buffer buffer, } // Same as with replacing, but we also need to free lines - free(lines[i]); + xfree(lines[i]); lines[i] = NULL; extra++; } @@ -301,10 +301,10 @@ void buffer_set_line_slice(Buffer buffer, end: for (size_t i = 0; i < new_len; i++) { - free(lines[i]); + xfree(lines[i]); } - free(lines); + xfree(lines); restore_win_for_buf(save_curwin, save_curtab, save_curbuf); try_end(err); } |