From cb56d76bd40ece75b9a20e567a35157d098bf0f1 Mon Sep 17 00:00:00 2001 From: markuspg Date: Thu, 26 Mar 2020 09:35:03 +0100 Subject: [PATCH] Modernize CmdCtx and CmdUsbCtx * move destructor of CmdCtx into separate translation unit to avoid spilling the vtable of CmdCtx into all translation units * utilize default member initializers --- libuuu/cmd.cpp | 3 +++ libuuu/cmd.h | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libuuu/cmd.cpp b/libuuu/cmd.cpp index 80659de..c65daf1 100644 --- a/libuuu/cmd.cpp +++ b/libuuu/cmd.cpp @@ -60,6 +60,9 @@ typedef void * (*FN)(); FN g_fn = create_object; +CmdCtx::~CmdCtx() +{ +} int CmdBase::parser(char *p) { diff --git a/libuuu/cmd.h b/libuuu/cmd.h index b1bb6cc..a48e406 100644 --- a/libuuu/cmd.h +++ b/libuuu/cmd.h @@ -50,17 +50,15 @@ uint32_t str_to_uint(string &str); class CmdCtx { public: - CmdCtx() { m_config_item = NULL; m_dev = NULL; }; - virtual ~CmdCtx() {}; - ConfigItem *m_config_item; - void *m_dev; + virtual ~CmdCtx(); + ConfigItem *m_config_item = nullptr; + void *m_dev = nullptr; }; class CmdUsbCtx : public CmdCtx { public: - CmdUsbCtx() :CmdCtx() {}; - ~CmdUsbCtx(); + ~CmdUsbCtx() override; int look_for_match_device(const char * procotol); }; -- 2.11.4.GIT