diff options
author | Nirav Atre <natre@google.com> | 2018-07-10 10:37:36 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-07-10 10:37:36 -0700 |
commit | 7896100023a1a68da135393bd4fe995353dacac3 (patch) | |
tree | c5c87313b4d34018b07041dd4f89342bbb766fa7 | |
parent | 82a6560f30df776a6b954f5ff77343487f5efb64 (diff) | |
parent | 2505641557b6020f289d098945230e65b0f41141 (diff) | |
download | libhidl-7896100023a1a68da135393bd4fe995353dacac3.tar.gz |
HIDL templated destructor
am: 2505641557
Change-Id: Iaddb411c04c4b5bd7fb5e77b3cf5bc0d699a927e
-rw-r--r-- | base/include/hidl/HidlInternal.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/base/include/hidl/HidlInternal.h b/base/include/hidl/HidlInternal.h index 5a08bc3..d000a87 100644 --- a/base/include/hidl/HidlInternal.h +++ b/base/include/hidl/HidlInternal.h @@ -48,6 +48,15 @@ void logAlwaysFatal(const char *message); // If "ro.vndk.version" is not set or set to "current", it returns empty string. std::string getVndkVersionStr(); +// Explicitly invokes the parameterized element's destructor; +// intended to be used alongside the placement new operator. +template<typename T> +void destructElement(T* element) { + if (element != nullptr) { + element->~T(); + } +} + // HIDL client/server code should *NOT* use this class. // // hidl_pointer wraps a pointer without taking ownership, |