Fixed the free and delete mismatch problem.

https://github.com/msgpack/msgpack-c/issues/52
This commit is contained in:
Takatoshi Kondo 2014-02-02 00:00:31 +00:00
parent ffd0525607
commit 81e26fe9b9

View File

@ -44,7 +44,17 @@ public:
void clear();
void swap(zone& o);
static void* operator new(std::size_t size) throw(std::bad_alloc)
{
void* p = ::malloc(size);
if (!p) throw std::bad_alloc();
return p;
}
static void operator delete(void *p) throw()
{
if (!p) return;
::free(p);
}
<%0.upto(GENERATION_LIMIT) {|i|%>
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>);