1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Remove forced alignment in operators new and delete

This alignment prevents umm_malloc to detect buffer overruns which fall within padding introduced by new/new[]. Allocated memory will be aligned by design of umm_malloc, so we don't need to pad anything here.
Also fixed some formatting/newlines and removed unused header files.
This commit is contained in:
Ivan Grokhotkov 2016-02-06 02:06:44 +03:00
parent 6fc141772c
commit 737f6c28ea

View File

@ -19,43 +19,41 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <debug.h> #include <debug.h>
extern "C" {
#include "ets_sys.h"
#include "os_type.h"
#include "osapi.h"
#include "mem.h"
}
#include <Arduino.h> #include <Arduino.h>
#include <cxxabi.h> #include <cxxabi.h>
using __cxxabiv1::__guard; using __cxxabiv1::__guard;
void *operator new(size_t size) { void *operator new(size_t size)
size = ((size + 3) & ~((size_t)0x3)); {
return os_malloc(size); return malloc(size);
} }
void *operator new[](size_t size) { void *operator new[](size_t size)
size = ((size + 3) & ~((size_t)0x3)); {
return os_malloc(size); return malloc(size);
} }
void operator delete(void * ptr) { void operator delete(void * ptr)
os_free(ptr); {
free(ptr);
} }
void operator delete[](void * ptr) { void operator delete[](void * ptr)
os_free(ptr); {
free(ptr);
} }
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
void __cxa_pure_virtual(void) { void __cxa_pure_virtual(void)
{
panic(); panic();
} }
void __cxa_deleted_virtual(void) { void __cxa_deleted_virtual(void)
{
panic(); panic();
} }
@ -87,20 +85,25 @@ extern "C" void __cxa_guard_abort(__guard* pg)
} }
namespace std { namespace std
void __throw_bad_function_call() { {
void __throw_bad_function_call()
{
panic(); panic();
} }
void __throw_length_error(char const*) { void __throw_length_error(char const*)
{
panic(); panic();
} }
void __throw_bad_alloc() { void __throw_bad_alloc()
{
panic(); panic();
} }
void __throw_logic_error(const char* str) { void __throw_logic_error(const char* str)
{
panic(); panic();
} }
} }