From cc999ff88323404f49c9d7b26ad01e21a35b650f Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 23 Jul 2018 02:55:56 +0000 Subject: [PATCH] Fix warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct menusave_t'; use assignment or value-initialization instead [-Wclass-memaccess] git-svn-id: https://svn.eduke32.com/eduke32@6950 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/savegame.cpp | 4 ++-- source/duke3d/src/savegame.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index 6d3861549..5425ec8a2 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -206,7 +206,7 @@ static void ReadSaveGameHeaders_Internal(void) size_t const numfiles = countcache1dfind(findfiles_default); size_t const internalsavesize = sizeof(menusave_t) * numfiles; g_internalsaves = (menusave_t *)Xrealloc(g_internalsaves, internalsavesize); - memset(g_internalsaves, 0, internalsavesize); + g_internalsaves->clear(); g_numinternalsaves = 0; ReadSaveGameHeaders_CACHE1D(findfiles_default); @@ -223,7 +223,7 @@ static void ReadSaveGameHeaders_Internal(void) } size_t const menusavesize = sizeof(menusave_t) * g_nummenusaves; g_menusaves = (menusave_t *)Xrealloc(g_menusaves, menusavesize); - memset(g_menusaves, 0, menusavesize); + g_menusaves->clear(); for (size_t x = g_numinternalsaves-1, y = 0; x < g_numinternalsaves; --x) { menusave_t & msv = g_internalsaves[x]; diff --git a/source/duke3d/src/savegame.h b/source/duke3d/src/savegame.h index d5f2c9869..38f3ad37f 100644 --- a/source/duke3d/src/savegame.h +++ b/source/duke3d/src/savegame.h @@ -98,6 +98,13 @@ struct menusave_t uint8_t isOldVer = 0; uint8_t isUnreadable = 0; uint8_t isAutoSave = 0; + void clear() + { + brief.reset(); + isOldVer = 0; + isUnreadable = 0; + isAutoSave = 0; + } }; extern savebrief_t g_lastautosave, g_lastusersave, g_freshload;