0
0
mirror of https://github.com/vim/vim.git synced 2025-10-07 05:54:16 -04:00

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.
This commit is contained in:
Bram Moolenaar
2018-02-09 12:29:56 +01:00
parent 0562532c2e
commit 1567558b20
4 changed files with 30 additions and 25 deletions

View File

@@ -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, int maxlen)
if (c2 == NUL) /* full match */
return 0;
s = q;
i = j;
i = j;
break;
}