Chromium Code Reviews| 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 if (reportType == 0) // _CRT_WARN | |
|
rvargas (doing something else)
2011/11/07 18:53:50
It is not clear to me that this is the right thing
| |
| 111 return 0; | |
| 112 // Remaining alternatives are _CRT_ERROR, and _CRT_ASSERT. | |
| 113 char* p = NULL; | |
| 114 *p = '0'; | |
|
rvargas (doing something else)
2011/11/07 18:53:50
Can we just DCHECK here instead? You're probably t
| |
| 109 return 0; | 115 return 0; |
| 110 } | 116 } |
| 111 | 117 |
| 112 int _CrtDbgReportW(int, const wchar_t*, int, const wchar_t*, | 118 int _CrtDbgReport(int reportType, |
| 113 const wchar_t*, ...) { | 119 const char*, |
| 114 return 0; | 120 int, const char*, |
| 121 const char*, | |
| 122 ...) { | |
| 123 return error_handler(reportType); | |
| 124 } | |
| 125 | |
| 126 int _CrtDbgReportW(int reportType, | |
| 127 const wchar_t*, | |
| 128 int, const wchar_t*, | |
| 129 const wchar_t*, | |
| 130 ...) { | |
| 131 return error_handler(reportType); | |
| 115 } | 132 } |
| 116 | 133 |
| 117 int _CrtSetReportMode(int, int) { | 134 int _CrtSetReportMode(int, int) { |
| 118 return 0; | 135 return 0; |
| 119 } | 136 } |
| 120 | 137 |
| 121 void* _malloc_dbg(size_t size, int , const char*, int) { | 138 void* _malloc_dbg(size_t size, int , const char*, int) { |
| 122 return malloc(size); | 139 return malloc(size); |
| 123 } | 140 } |
| 124 | 141 |
| 125 void _free_dbg(void* ptr, int) { | 142 void _free_dbg(void* ptr, int) { |
| 126 free(ptr); | 143 free(ptr); |
| 127 } | 144 } |
| 128 | 145 |
| 129 void* _calloc_dbg(size_t n, size_t size, int, const char*, int) { | 146 void* _calloc_dbg(size_t n, size_t size, int, const char*, int) { |
| 130 return calloc(n, size); | 147 return calloc(n, size); |
| 131 } | 148 } |
| 132 #endif // NDEBUG | 149 #endif // NDEBUG |
| 133 | 150 |
| 134 #endif // WIN32 | 151 #endif // WIN32 |
| 135 | 152 |
| 136 } // extern C | 153 } // extern C |
| 137 | 154 |
| OLD | NEW |