Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4535 from yebblies/rmemsplit
[DDMD] Split C++ operator new declaration into a new file
- Loading branch information
Showing
4 changed files
with
63 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
/* Copyright (c) 2000-2014 by Digital Mars | ||
* All Rights Reserved, written by Walter Bright | ||
* http://www.digitalmars.com | ||
* Distributed under the Boost Software License, Version 1.0. | ||
* (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/rmem.c | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#if defined(__has_feature) | ||
#if __has_feature(address_sanitizer) | ||
#define USE_ASAN_NEW_DELETE | ||
#endif | ||
#endif | ||
|
||
#if !defined(USE_ASAN_NEW_DELETE) | ||
|
||
#if 1 | ||
|
||
void *allocmemory(size_t m_size); | ||
|
||
void * operator new(size_t m_size) | ||
{ | ||
return allocmemory(m_size); | ||
} | ||
|
||
void operator delete(void *p) | ||
{ | ||
} | ||
|
||
#else | ||
|
||
void * operator new(size_t m_size) | ||
{ | ||
void *p = malloc(m_size); | ||
if (p) | ||
return p; | ||
printf("Error: out of memory\n"); | ||
exit(EXIT_FAILURE); | ||
return p; | ||
} | ||
|
||
void operator delete(void *p) | ||
{ | ||
free(p); | ||
} | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters