| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // When possible, we implement allocator functions on top of the basic | 5 // When possible, we implement allocator functions on top of the basic |
| 6 // low-level functions malloc() and free(). This way, including a new | 6 // low-level functions malloc() and free(). This way, including a new |
| 7 // allocator is as simple as providing just a small interface. | 7 // allocator is as simple as providing just a small interface. |
| 8 // | 8 // |
| 9 // As such, this file should not contain any allocator-specific code. | 9 // As such, this file should not contain any allocator-specific code. |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 void* _calloc_impl(size_t n, size_t size) { | 100 void* _calloc_impl(size_t n, size_t size) { |
| 101 return calloc(n, size); | 101 return calloc(n, size); |
| 102 } | 102 } |
| 103 | 103 |
| 104 #ifndef NDEBUG | 104 #ifndef NDEBUG |
| 105 #undef malloc | 105 #undef malloc |
| 106 #undef free | 106 #undef free |
| 107 #undef calloc | 107 #undef calloc |
| 108 int _CrtDbgReport(int, const char*, int, const char*, const char*, ...) { | 108 |
| 109 static int error_handler(int reportType) { |
| 110 switch (reportType) { |
| 111 case 0: // _CRT_WARN |
| 112 __debugbreak(); |
| 113 return 0; |
| 114 |
| 115 case 1: // _CRT_ERROR |
| 116 __debugbreak(); |
| 117 return 0; |
| 118 |
| 119 case 2: // _CRT_ASSERT |
| 120 __debugbreak(); |
| 121 return 0; |
| 122 } |
| 123 char* p = NULL; |
| 124 *p = '\0'; |
| 109 return 0; | 125 return 0; |
| 110 } | 126 } |
| 111 | 127 |
| 112 int _CrtDbgReportW(int, const wchar_t*, int, const wchar_t*, | 128 int _CrtDbgReport(int reportType, |
| 113 const wchar_t*, ...) { | 129 const char*, |
| 114 return 0; | 130 int, const char*, |
| 131 const char*, |
| 132 ...) { |
| 133 return error_handler(reportType); |
| 134 } |
| 135 |
| 136 int _CrtDbgReportW(int reportType, |
| 137 const wchar_t*, |
| 138 int, const wchar_t*, |
| 139 const wchar_t*, |
| 140 ...) { |
| 141 return error_handler(reportType); |
| 115 } | 142 } |
| 116 | 143 |
| 117 int _CrtSetReportMode(int, int) { | 144 int _CrtSetReportMode(int, int) { |
| 118 return 0; | 145 return 0; |
| 119 } | 146 } |
| 120 | 147 |
| 121 void* _malloc_dbg(size_t size, int , const char*, int) { | 148 void* _malloc_dbg(size_t size, int , const char*, int) { |
| 122 return malloc(size); | 149 return malloc(size); |
| 123 } | 150 } |
| 124 | 151 |
| 125 void _free_dbg(void* ptr, int) { | 152 void _free_dbg(void* ptr, int) { |
| 126 free(ptr); | 153 free(ptr); |
| 127 } | 154 } |
| 128 | 155 |
| 129 void* _calloc_dbg(size_t n, size_t size, int, const char*, int) { | 156 void* _calloc_dbg(size_t n, size_t size, int, const char*, int) { |
| 130 return calloc(n, size); | 157 return calloc(n, size); |
| 131 } | 158 } |
| 132 #endif // NDEBUG | 159 #endif // NDEBUG |
| 133 | 160 |
| 134 #endif // WIN32 | 161 #endif // WIN32 |
| 135 | 162 |
| 136 } // extern C | 163 } // extern C |
| 137 | 164 |
| OLD | NEW |