Jelajahi Sumber

Fix final leak (win32 only).

kenton@google.com 16 tahun lalu
induk
melakukan
b43727981c
2 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 6 0
      src/google/protobuf/stubs/once.cc
  2. 1 0
      src/google/protobuf/stubs/once.h

+ 6 - 0
src/google/protobuf/stubs/once.cc

@@ -56,6 +56,12 @@ struct GoogleOnceInternal {
   CRITICAL_SECTION critical_section;
 };
 
+GoogleOnceType::~GoogleOnceType()
+{
+  delete internal_;
+  internal_ = NULL;
+}
+
 GoogleOnceType::GoogleOnceType() {
   // internal_ may be non-NULL if Init() was already called.
   if (internal_ == NULL) internal_ = new GoogleOnceInternal;

+ 1 - 0
src/google/protobuf/stubs/once.h

@@ -87,6 +87,7 @@ struct GoogleOnceInternal;
 
 struct LIBPROTOBUF_EXPORT GoogleOnceType {
   GoogleOnceType();
+  ~GoogleOnceType();
   void Init(void (*init_func)());
 
   volatile bool initialized_;