diff src/undo.c @ 20007:aadd1cae2ff5 v8.2.0559

patch 8.2.0559: clearing a struct is verbose Commit: https://github.com/vim/vim/commit/a80faa8930ed5a554beeb2727762538873135e83 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 12 19:37:17 2020 +0200 patch 8.2.0559: clearing a struct is verbose Problem: Clearing a struct is verbose. Solution: Define and use CLEAR_FIELD() and CLEAR_POINTER().
author Bram Moolenaar <Bram@vim.org>
date Sun, 12 Apr 2020 19:45:05 +0200
parents 15539899a112
children 252d2bb90394
line wrap: on
line diff
--- a/src/undo.c
+++ b/src/undo.c
@@ -662,7 +662,7 @@ u_savecommon(
     uep = U_ALLOC_LINE(sizeof(u_entry_T));
     if (uep == NULL)
 	goto nomem;
-    vim_memset(uep, 0, sizeof(u_entry_T));
+    CLEAR_POINTER(uep);
 #ifdef U_DEBUG
     uep->ue_magic = UE_MAGIC;
 #endif
@@ -1288,7 +1288,7 @@ unserialize_uhp(bufinfo_T *bi, char_u *f
     uhp = U_ALLOC_LINE(sizeof(u_header_T));
     if (uhp == NULL)
 	return NULL;
-    vim_memset(uhp, 0, sizeof(u_header_T));
+    CLEAR_POINTER(uhp);
 #ifdef U_DEBUG
     uhp->uh_magic = UH_MAGIC;
 #endif
@@ -1405,7 +1405,7 @@ unserialize_uep(bufinfo_T *bi, int *erro
     uep = U_ALLOC_LINE(sizeof(u_entry_T));
     if (uep == NULL)
 	return NULL;
-    vim_memset(uep, 0, sizeof(u_entry_T));
+    CLEAR_POINTER(uep);
 #ifdef U_DEBUG
     uep->ue_magic = UE_MAGIC;
 #endif
@@ -1532,7 +1532,7 @@ u_write_undo(
 #endif
     bufinfo_T	bi;
 
-    vim_memset(&bi, 0, sizeof(bi));
+    CLEAR_FIELD(bi);
 
     if (name == NULL)
     {
@@ -1814,7 +1814,7 @@ u_read_undo(char_u *name, char_u *hash, 
 #endif
     bufinfo_T	bi;
 
-    vim_memset(&bi, 0, sizeof(bi));
+    CLEAR_FIELD(bi);
     line_ptr.ul_len = 0;
     line_ptr.ul_line = NULL;