| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
| 6 | 6 |
| 7 #include "base/process/memory.h" | 7 #include "base/process/memory.h" |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 public: | 175 public: |
| 176 OutOfMemoryTest() | 176 OutOfMemoryTest() |
| 177 : value_(NULL), | 177 : value_(NULL), |
| 178 // Make test size as large as possible minus a few pages so | 178 // Make test size as large as possible minus a few pages so |
| 179 // that alignment or other rounding doesn't make it wrap. | 179 // that alignment or other rounding doesn't make it wrap. |
| 180 test_size_(std::numeric_limits<std::size_t>::max() - 12 * 1024), | 180 test_size_(std::numeric_limits<std::size_t>::max() - 12 * 1024), |
| 181 signed_test_size_(std::numeric_limits<ssize_t>::max()) { | 181 signed_test_size_(std::numeric_limits<ssize_t>::max()) { |
| 182 } | 182 } |
| 183 | 183 |
| 184 #if defined(USE_TCMALLOC) | 184 #if defined(USE_TCMALLOC) |
| 185 virtual void SetUp() OVERRIDE { | 185 virtual void SetUp() override { |
| 186 tc_set_new_mode(1); | 186 tc_set_new_mode(1); |
| 187 } | 187 } |
| 188 | 188 |
| 189 virtual void TearDown() OVERRIDE { | 189 virtual void TearDown() override { |
| 190 tc_set_new_mode(0); | 190 tc_set_new_mode(0); |
| 191 } | 191 } |
| 192 #endif // defined(USE_TCMALLOC) | 192 #endif // defined(USE_TCMALLOC) |
| 193 | 193 |
| 194 protected: | 194 protected: |
| 195 void* value_; | 195 void* value_; |
| 196 size_t test_size_; | 196 size_t test_size_; |
| 197 ssize_t signed_test_size_; | 197 ssize_t signed_test_size_; |
| 198 }; | 198 }; |
| 199 | 199 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 bytes = static_cast<const char*>(value_); | 442 bytes = static_cast<const char*>(value_); |
| 443 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) | 443 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) |
| 444 EXPECT_EQ(0, bytes[i]); | 444 EXPECT_EQ(0, bytes[i]); |
| 445 free(value_); | 445 free(value_); |
| 446 | 446 |
| 447 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); | 447 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); |
| 448 EXPECT_TRUE(value_ == NULL); | 448 EXPECT_TRUE(value_ == NULL); |
| 449 } | 449 } |
| 450 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 450 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| 451 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !defined(OS_WIN) | 451 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !defined(OS_WIN) |
| OLD | NEW |