Commit 55d8c7c8 authored by Alexey Kozhevnikov's avatar Alexey Kozhevnikov Committed by Facebook Github Bot

Avoid C4291 warning in IOBuf.cpp on Windows

Summary:
Warning: https://msdn.microsoft.com/en-us/library/cxdxz3x6.aspx

Provide matching placement delete operator to avoid the false-positive MSVC warning about memory leak when exception is thrown inside the constructor.

Reviewed By: yfeldblum

Differential Revision: D9773561

fbshipit-source-id: e6c4ab1d230e567491271c4cc2c23cd98469e672
parent 1a504d88
...@@ -148,6 +148,12 @@ void IOBuf::operator delete(void* ptr) { ...@@ -148,6 +148,12 @@ void IOBuf::operator delete(void* ptr) {
releaseStorage(storage, kIOBufInUse); releaseStorage(storage, kIOBufInUse);
} }
void IOBuf::operator delete(void* /* ptr */, void* /* placement */) {
// Provide matching operator for `IOBuf::new` to avoid MSVC compilation
// warning (C4291) about memory leak when exception is thrown in the
// constructor.
}
void IOBuf::releaseStorage(HeapStorage* storage, uint16_t freeFlags) { void IOBuf::releaseStorage(HeapStorage* storage, uint16_t freeFlags) {
CHECK_EQ(storage->prefix.magic, static_cast<uint16_t>(kHeapMagic)); CHECK_EQ(storage->prefix.magic, static_cast<uint16_t>(kHeapMagic));
......
...@@ -1238,6 +1238,7 @@ class IOBuf { ...@@ -1238,6 +1238,7 @@ class IOBuf {
void* operator new(size_t size); void* operator new(size_t size);
void* operator new(size_t size, void* ptr); void* operator new(size_t size, void* ptr);
void operator delete(void* ptr); void operator delete(void* ptr);
void operator delete(void* ptr, void* placement);
/** /**
* Destructively convert this IOBuf to a fbstring efficiently. * Destructively convert this IOBuf to a fbstring efficiently.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment