| OLD | NEW |
| 1 /* Copyright (c) 2006, Google Inc. | 1 /* Copyright (c) 2006, Google Inc. |
| 2 * All rights reserved. | 2 * All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 // A test for low_level_alloc.cc | 31 // A test for low_level_alloc.cc |
| 32 | 32 |
| 33 #include <stdio.h> | 33 #include <stdio.h> |
| 34 #include <map> | 34 #include <map> |
| 35 #include "base/low_level_alloc.h" | 35 #include "base/low_level_alloc.h" |
| 36 #include "base/logging.h" | 36 #include "base/logging.h" |
| 37 #include <google/malloc_hook.h> | 37 #include <gperftools/malloc_hook.h> |
| 38 | 38 |
| 39 using std::map; | 39 using std::map; |
| 40 | 40 |
| 41 // a block of memory obtained from the allocator | 41 // a block of memory obtained from the allocator |
| 42 struct BlockDesc { | 42 struct BlockDesc { |
| 43 char *ptr; // pointer to memory | 43 char *ptr; // pointer to memory |
| 44 int len; // number of bytes | 44 int len; // number of bytes |
| 45 int fill; // filled with data starting with this | 45 int fill; // filled with data starting with this |
| 46 }; | 46 }; |
| 47 | 47 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } else { | 187 } else { |
| 188 CHECK_EQ(allocates, 0); // arena doesn't call hooks | 188 CHECK_EQ(allocates, 0); // arena doesn't call hooks |
| 189 CHECK_EQ(frees, 0); | 189 CHECK_EQ(frees, 0); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 printf("\nPASS\n"); | 192 printf("\nPASS\n"); |
| 193 CHECK(MallocHook::RemoveNewHook(&AllocHook)); | 193 CHECK(MallocHook::RemoveNewHook(&AllocHook)); |
| 194 CHECK(MallocHook::RemoveDeleteHook(&FreeHook)); | 194 CHECK(MallocHook::RemoveDeleteHook(&FreeHook)); |
| 195 return 0; | 195 return 0; |
| 196 } | 196 } |
| OLD | NEW |