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/mbyte.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/mbyte.c')
-rw-r--r-- | src/nvim/mbyte.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index fd6050f2d6..e45d43270a 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -523,7 +523,7 @@ char_u * mb_init(void) convert_setup(&vimconv, p_enc, (char_u *)"utf-8"); vimconv.vc_fail = true; } - free(p); + xfree(p); } #endif @@ -549,7 +549,7 @@ char_u * mb_init(void) */ p = string_convert(&vimconv, (char_u *)buf, NULL); if (p != NULL) { - free(p); + xfree(p); n = 1; } else n = 2; @@ -3103,7 +3103,7 @@ void utf_find_illegal(void) for (;; ) { p = get_cursor_pos_ptr(); if (vimconv.vc_type != CONV_NONE) { - free(tofree); + xfree(tofree); tofree = string_convert(&vimconv, p, NULL); if (tofree == NULL) break; @@ -3142,7 +3142,7 @@ void utf_find_illegal(void) beep_flush(); theend: - free(tofree); + xfree(tofree); convert_setup(&vimconv, NULL, NULL); } @@ -3375,7 +3375,7 @@ char_u *enc_canonize(char_u *enc) FUNC_ATTR_NONNULL_RET STRMOVE(r, p); } else if ((i = enc_alias_search(p)) >= 0) { /* alias recognized, get canonical name */ - free(r); + xfree(r); r = vim_strsave((char_u *)enc_canon_table[i].name); } return r; @@ -3537,7 +3537,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, size_t slen, p = xmalloc(len); if (done > 0) memmove(p, result, done); - free(result); + xfree(result); result = p; } @@ -3582,7 +3582,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, size_t slen, fromlen -= l; } else if (ICONV_ERRNO != ICONV_E2BIG) { /* conversion failed */ - free(result); + xfree(result); result = NULL; break; } @@ -3891,7 +3891,7 @@ char_u * string_convert_ext(vimconv_T *vcp, char_u *ptr, if (l_w == 0) { /* Illegal utf-8 byte cannot be converted */ - free(retval); + xfree(retval); return NULL; } if (unconvlenp != NULL && l_w > len - i) { @@ -3925,7 +3925,7 @@ char_u * string_convert_ext(vimconv_T *vcp, char_u *ptr, if (c < 0x100) *d++ = c; else if (vcp->vc_fail) { - free(retval); + xfree(retval); return NULL; } else { *d++ = 0xbf; |