github.com/moontrade/nogc@v0.1.7/alloc/rpmalloc/src/rpnew.h (about)

     1  
     2  #ifdef __cplusplus
     3  
     4  #include <new>
     5  #include <rpmalloc.h>
     6  
     7  #ifdef _WIN32
     8  
     9  extern void __CRTDECL
    10  operator delete(void* p) noexcept {
    11  	rpfree(p);
    12  }
    13  
    14  extern void __CRTDECL
    15  operator delete[](void* p) noexcept {
    16  	rpfree(p);
    17  }
    18  
    19  extern void* __CRTDECL
    20  operator new(std::size_t size) noexcept(false) {
    21  	return rpmalloc(size);
    22  }
    23  
    24  extern void* __CRTDECL
    25  operator new[](std::size_t size) noexcept(false) {
    26  	return rpmalloc(size);
    27  }
    28  
    29  extern void* __CRTDECL
    30  operator new(std::size_t size, const std::nothrow_t& tag) noexcept {
    31  	(void)sizeof(tag);
    32  	return rpmalloc(size);
    33  }
    34  
    35  extern void* __CRTDECL
    36  operator new[](std::size_t size, const std::nothrow_t& tag) noexcept {
    37  	(void)sizeof(tag);
    38  	return rpmalloc(size);
    39  }
    40  
    41  #if (__cplusplus >= 201402L || _MSC_VER >= 1916)
    42  
    43  extern void __CRTDECL
    44  operator delete(void* p, std::size_t size) noexcept {
    45  	(void)sizeof(size);
    46  	rpfree(p);
    47  }
    48  
    49  extern void __CRTDECL
    50  operator delete[](void* p, std::size_t size) noexcept {
    51  	(void)sizeof(size);
    52  	rpfree(p);
    53  }
    54  
    55  #endif
    56  
    57  #if (__cplusplus > 201402L || defined(__cpp_aligned_new))
    58  
    59  extern void __CRTDECL
    60  operator delete(void* p, std::align_val_t align) noexcept {
    61  	(void)sizeof(align);
    62  	rpfree(p);
    63  }
    64  
    65  extern void __CRTDECL
    66  operator delete[](void* p, std::align_val_t align) noexcept {
    67  	(void)sizeof(align);
    68  	rpfree(p);
    69  }
    70  
    71  extern void __CRTDECL
    72  operator delete(void* p, std::size_t size, std::align_val_t align) noexcept {
    73  	(void)sizeof(size);
    74  	(void)sizeof(align);
    75  	rpfree(p);
    76  }
    77  
    78  extern void __CRTDECL
    79  operator delete[](void* p, std::size_t size, std::align_val_t align) noexcept {
    80  	(void)sizeof(size);
    81  	(void)sizeof(align);
    82  	rpfree(p);
    83  }
    84  
    85  extern void* __CRTDECL
    86  operator new(std::size_t size, std::align_val_t align) noexcept(false) {
    87  	return rpaligned_alloc(align, size);
    88  }
    89  
    90  extern void* __CRTDECL
    91  operator new[](std::size_t size, std::align_val_t align) noexcept(false) {
    92  	return rpaligned_alloc(align, size);
    93  }
    94  
    95  extern void* __CRTDECL
    96  operator new(std::size_t size, std::align_val_t align, const std::nothrow_t& tag) noexcept {
    97  	(void)sizeof(tag);
    98  	return rpaligned_alloc(align, size);
    99  }
   100  
   101  extern void* __CRTDECL
   102  operator new[](std::size_t size, std::align_val_t align, const std::nothrow_t& tag) noexcept {
   103  	(void)sizeof(tag);
   104  	return rpaligned_alloc(align, size);
   105  }
   106  
   107  #endif
   108  
   109  #endif
   110  
   111  #endif