Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: third_party/tcmalloc/chromium/src/tcmalloc.cc

Issue 55333002: Make possible to check memory allocations inside chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ATTRIBUTE_SECTION(google_malloc); 262 ATTRIBUTE_SECTION(google_malloc);
263 263
264 // Some non-standard extensions that we support. 264 // Some non-standard extensions that we support.
265 265
266 // This is equivalent to 266 // This is equivalent to
267 // OS X: malloc_size() 267 // OS X: malloc_size()
268 // glibc: malloc_usable_size() 268 // glibc: malloc_usable_size()
269 // Windows: _msize() 269 // Windows: _msize()
270 size_t tc_malloc_size(void* p) __THROW 270 size_t tc_malloc_size(void* p) __THROW
271 ATTRIBUTE_SECTION(google_malloc); 271 ATTRIBUTE_SECTION(google_malloc);
272
273 // This does not call the new handler but let the caller
274 // check whether the allocation succeed.
275 void* tc_try_malloc(size_t size) __THROW
276 ATTRIBUTE_SECTION(google_malloc);
272 } // extern "C" 277 } // extern "C"
273 278
274 279
275 // ----------------------- IMPLEMENTATION ------------------------------- 280 // ----------------------- IMPLEMENTATION -------------------------------
276 281
277 static int tc_new_mode = 0; // See tc_set_new_mode(). 282 static int tc_new_mode = 0; // See tc_set_new_mode().
278 283
279 // Routines such as free() and realloc() catch some erroneous pointers 284 // Routines such as free() and realloc() catch some erroneous pointers
280 // passed to them, and invoke the below when they do. (An erroneous pointer 285 // passed to them, and invoke the below when they do. (An erroneous pointer
281 // won't be caught if it's within a valid span or a stale span for which 286 // won't be caught if it's within a valid span or a stale span for which
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 size = (size + pagesize - 1) & ~(pagesize - 1); 1703 size = (size + pagesize - 1) & ~(pagesize - 1);
1699 void* result = do_memalign_or_cpp_memalign(pagesize, size); 1704 void* result = do_memalign_or_cpp_memalign(pagesize, size);
1700 MallocHook::InvokeNewHook(result, size); 1705 MallocHook::InvokeNewHook(result, size);
1701 return result; 1706 return result;
1702 } 1707 }
1703 1708
1704 extern "C" PERFTOOLS_DLL_DECL void tc_malloc_stats(void) __THROW { 1709 extern "C" PERFTOOLS_DLL_DECL void tc_malloc_stats(void) __THROW {
1705 do_malloc_stats(); 1710 do_malloc_stats();
1706 } 1711 }
1707 1712
1713 extern "C" PERFTOOLS_DLL_DECL void* tc_try_malloc(size_t size) __THROW {
1714 return do_malloc(size);
1715 }
1716
1708 extern "C" PERFTOOLS_DLL_DECL int tc_mallopt(int cmd, int value) __THROW { 1717 extern "C" PERFTOOLS_DLL_DECL int tc_mallopt(int cmd, int value) __THROW {
1709 return do_mallopt(cmd, value); 1718 return do_mallopt(cmd, value);
1710 } 1719 }
1711 1720
1712 #ifdef HAVE_STRUCT_MALLINFO 1721 #ifdef HAVE_STRUCT_MALLINFO
1713 extern "C" PERFTOOLS_DLL_DECL struct mallinfo tc_mallinfo(void) __THROW { 1722 extern "C" PERFTOOLS_DLL_DECL struct mallinfo tc_mallinfo(void) __THROW {
1714 return do_mallinfo(); 1723 return do_mallinfo();
1715 } 1724 }
1716 #endif 1725 #endif
1717 1726
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 *mark = ~allocated_mark; // Distinctively not allocated. 1880 *mark = ~allocated_mark; // Distinctively not allocated.
1872 } 1881 }
1873 1882
1874 static void MarkAllocatedRegion(void* ptr) { 1883 static void MarkAllocatedRegion(void* ptr) {
1875 if (ptr == NULL) return; 1884 if (ptr == NULL) return;
1876 MarkType* mark = GetMarkLocation(ptr); 1885 MarkType* mark = GetMarkLocation(ptr);
1877 *mark = GetMarkValue(ptr, mark); 1886 *mark = GetMarkValue(ptr, mark);
1878 } 1887 }
1879 1888
1880 #endif // TCMALLOC_VALIDATION 1889 #endif // TCMALLOC_VALIDATION
OLDNEW
« base/process/memory_linux.cc ('K') | « third_party/tcmalloc/chromium/src/debugallocation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698