summaryrefslogtreecommitdiff
path: root/src/misc2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-02-09 12:29:56 +0100
committerBram Moolenaar <Bram@vim.org>2018-02-09 12:29:56 +0100
commit1567558b20575e1b17c3808c6bd622b0b4810e36 (patch)
tree99daa4315bad8425010182fc21c12516a5c96713 /src/misc2.c
parent0562532c2eee6205d225aa1dc7e3e89af0dfd990 (diff)
downloadvim-git-1567558b20575e1b17c3808c6bd622b0b4810e36.tar.gz
patch 8.0.1481: clearing a pointer takes two linesv8.0.1481
Problem: Clearing a pointer takes two lines. Solution: Add vim_clear() to free and clear the pointer.
Diffstat (limited to 'src/misc2.c')
-rw-r--r--src/misc2.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/misc2.c b/src/misc2.c
index f089051ef..368303ed9 100644
--- 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, int maxlen)
if (c2 == NUL) /* full match */
return 0;
s = q;
- i = j;
+ i = j;
break;
}