From 3c024cc22f19fa0d809dbfe3050257998def6e78 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 17 Sep 1998 14:31:17 +0000 Subject: [PATCH] fixed 64but bug with g_strEmpty initialization git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@742 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/string.h | 2 +- src/common/string.cpp | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/wx/string.h b/include/wx/string.h index 978ee25b77..44d6803a1b 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -125,7 +125,7 @@ inline const wxString& wxGetEmptyString() { return *(wxString *)&g_szNul; } struct WXDLLEXPORT wxStringData { int nRefs; // reference count - size_t nDataLength, // actual string length + size_t nDataLength, // actual string length nAllocLength; // allocated memory size // mimics declaration 'char data[nAllocLength]' diff --git a/src/common/string.cpp b/src/common/string.cpp index 05dce3179b..1bcf9bff83 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -32,9 +32,9 @@ #endif #ifndef WX_PRECOMP -#include "wx/defs.h" -#include "wx/string.h" -#include + #include "wx/defs.h" + #include "wx/string.h" + #include "wx/intl.h" #endif #include @@ -62,13 +62,17 @@ // static data // ---------------------------------------------------------------------------- -// for an empty string, GetStringData() will return this address -static int g_strEmpty[] = { -1, // ref count (locked) - 0, // current length - 0, // allocated memory - 0 }; // string data +// for an empty string, GetStringData() will return this address: this +// structure has the same layout as wxStringData and it's data() method will +// return the empty string (dummy pointer) +static const struct +{ + wxStringData data; + char dummy; +} g_strEmpty = { {-1, 0, 0}, '\0' }; + // empty C style string: points to 'string data' byte of g_strEmpty -extern const char *g_szNul = (const char *)(&g_strEmpty[3]); +extern const char *g_szNul = &g_strEmpty.dummy; // ---------------------------------------------------------------------------- // global functions -- 2.45.2