Mercurial > vim
diff src/misc2.c @ 13214:ed51483e9971
patch 8.0.1481: clearing a pointer takes two lines
commit https://github.com/vim/vim/commit/1567558b20575e1b17c3808c6bd622b0b4810e36
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 9 12:29:56 2018 +0100
patch 8.0.1481: clearing a pointer takes two lines
Problem: Clearing a pointer takes two lines.
Solution: Add vim_clear() to free and clear the pointer.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 09 Feb 2018 12:30:07 +0100 |
parents | 7ab8c5983983 |
children | fee03d646e42 |
line wrap: on
line diff
--- a/src/misc2.c +++ b/src/misc2.c @@ -1836,6 +1836,19 @@ vim_free(void *x) } } +/* + * Like vim_free(), and also set the pointer to NULL. + */ + void +vim_clear(void **x) +{ + if (*x != NULL) + { + vim_free(*x); + *x = NULL; + } +} + #ifndef HAVE_MEMSET void * vim_memset(void *ptr, int c, size_t size) @@ -5173,8 +5186,8 @@ ff_wc_equal(char_u *s1, char_u *s2) prev2 = prev1; prev1 = c1; - i += MB_PTR2LEN(s1 + i); - j += MB_PTR2LEN(s2 + j); + i += MB_PTR2LEN(s1 + i); + j += MB_PTR2LEN(s2 + j); } return s1[i] == s2[j]; } @@ -5892,7 +5905,7 @@ pathcmp(const char *p, const char *q, in if (c2 == NUL) /* full match */ return 0; s = q; - i = j; + i = j; break; }