]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
Make it possible to use wxCharBuffer during program initialization.
[wxWidgets.git] / src / common / string.cpp
index 9e9ba528fcbd6b11bd7c64154fa70179ecba8563..dcac014916affa78c76d317829b52d2a74ced9d3 100644 (file)
     #define wxStringStrlen   wxStrlen
 #endif
 
-// ----------------------------------------------------------------------------
-// global variables
-// ----------------------------------------------------------------------------
-
+// define a function declared in wx/buffer.h here as we don't have buffer.cpp
+// and don't want to add it just because of this simple function
 namespace wxPrivate
 {
 
-static UntypedBufferData s_untypedNullData(NULL, 0);
+// wxXXXBuffer classes can be (implicitly) used during global statics
+// initialization so wrap the status UntypedBufferData variable in a function
+// to make it safe to access it even before all global statics are initialized
+UntypedBufferData *GetUntypedNullData()
+{
+    static UntypedBufferData s_untypedNullData(NULL, 0);
 
-UntypedBufferData * const untypedNullDataPtr = &s_untypedNullData;
+    return &s_untypedNullData;
+}
 
 } // namespace wxPrivate