diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-05-06 19:27:03 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-05-06 19:27:03 +0000 |
commit | 63e646b7ad6f18228c1807f8d18111ae96e86aa7 (patch) | |
tree | fc524e6f55b32b7d786bd41623402394a2f1af26 /src/google/protobuf/stubs/common.h | |
parent | 9824eda6b558cd88c63064017593521ecad2029f (diff) | |
download | protobuf-63e646b7ad6f18228c1807f8d18111ae96e86aa7.tar.gz protobuf-63e646b7ad6f18228c1807f8d18111ae96e86aa7.tar.bz2 protobuf-63e646b7ad6f18228c1807f8d18111ae96e86aa7.zip |
Provide ShutdownProtobufLibrary() which frees all startup-allocated objects.
Diffstat (limited to 'src/google/protobuf/stubs/common.h')
-rw-r--r-- | src/google/protobuf/stubs/common.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 4a55e004..3367d4ce 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -1085,6 +1085,31 @@ LIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len); } // namespace internal +// =================================================================== +// Shutdown support. + +// Shut down the entire protocol buffers library, deleting all static-duration +// objects allocated by the library or by generated .pb.cc files. +// +// There are two reasons you might want to call this: +// * You use a draconian definition of "memory leak" in which you expect +// every single malloc() to have a corresponding free(), even for objects +// which live until program exit. +// * You are writing a dynamically-loaded library which needs to clean up +// after itself when the library is unloaded. +// +// It is safe to call this multiple times. However, it is not safe to use +// any other part of the protocol buffers library after +// ShutdownProtobufLibrary() has been called. +LIBPROTOBUF_EXPORT void ShutdownProtobufLibrary(); + +namespace internal { + +// Register a function to be called when ShutdownProtocolBuffers() is called. +LIBPROTOBUF_EXPORT void OnShutdown(void (*func)()); + +} // namespace internal + } // namespace protobuf } // namespace google |