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.
diff --git a/src/misc2.c b/src/misc2.c
index f089051..368303e 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1836,6 +1836,19 @@
}
}
+/*
+ * 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 @@
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 @@
if (c2 == NUL) /* full match */
return 0;
s = q;
- i = j;
+ i = j;
break;
}