Skip to content

Commit

Permalink
Fix build on GCC, c++14 sized deallocation
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Jan 27, 2018
1 parent e3b4e72 commit c0eba39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/crt/cxxabi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <cstddef>
#include <cstring>
#include <kprint.hpp>
extern "C" void* malloc(size_t);
extern "C" void free(void*);

//#define DEBUG_HEAP
#ifdef DEBUG_HEAP
Expand Down Expand Up @@ -33,6 +35,15 @@ void operator delete[](void* ptr)
HPRINT("operator delete[]: %p\n", ptr);
free(ptr);
}
// C++14 sized deallocation
void operator delete(void* ptr, std::size_t)
{
free(ptr);
}
void operator delete [](void* ptr, std::size_t)
{
free(ptr);
}

extern "C" void __cxa_pure_virtual()
{
Expand Down
2 changes: 1 addition & 1 deletion src/crt/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <errno.h>

static inline size_t word_align(size_t size) {
return size + (sizeof(size_t) - 1) & ~(sizeof(size_t) - 1);
return size + ((sizeof(size_t) - 1) & ~(sizeof(size_t) - 1));
}

struct chunk {
Expand Down

0 comments on commit c0eba39

Please sign in to comment.