diff src/misc2.c @ 13244:ac42c4b11dbc v8.0.1496

patch 8.0.1496: clearing a pointer takes two lines commit https://github.com/vim/vim/commit/d23a823669d93fb2a570a039173eefe4856ac806 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 10 18:45:26 2018 +0100 patch 8.0.1496: clearing a pointer takes two lines Problem: Clearing a pointer takes two lines. Solution: Add VIM_CLEAR() and replace vim_clear(). (Hirohito Higashi, closes #2629)
author Christian Brabandt <cb@256bit.org>
date Sat, 10 Feb 2018 19:00:07 +0100
parents fee03d646e42
children 69517d67421f
line wrap: on
line diff
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1827,6 +1827,8 @@ copy_option_part(
  * Replacement for free() that ignores NULL pointers.
  * Also skip free() when exiting for sure, this helps when we caught a deadly
  * signal that was caused by a crash in free().
+ * If you want to set NULL after calling this function, you should use
+ * VIM_CLEAR() instead.
  */
     void
 vim_free(void *x)
@@ -1840,19 +1842,6 @@ 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)