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

Unified Diff: base/allocator/allocator_shim_default_dispatch_to_glibc.cc

Issue 2163783003: Implement a ScopedThreadHeapUsage class to allow profiling per-thread heap usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shim-default
Patch Set: Fix a brain****, may even compile now. Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: base/allocator/allocator_shim_default_dispatch_to_glibc.cc
diff --git a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
index 02facbad2eb7cff333e4f9ab6a78b5cffeb52632..a946c36894e220eea7e39b52a006b7ca27cb6d6e 100644
--- a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
+++ b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
@@ -14,6 +14,7 @@ void* __libc_calloc(size_t n, size_t size);
void* __libc_realloc(void* address, size_t size);
void* __libc_memalign(size_t alignment, size_t size);
void __libc_free(void* ptr);
+size_t __malloc_usable_size(void* ptr);
Primiano Tucci (use gerrit) 2016/08/24 15:28:46 not sure you ned this fwd declaration
Sigurður Ásgeirsson 2016/09/01 15:18:17 Done.
} // extern "C"
namespace {
@@ -39,14 +40,23 @@ void* GlibcMemalign(const AllocatorDispatch*, size_t alignment, size_t size) {
void GlibcFree(const AllocatorDispatch*, void* address) {
__libc_free(address);
}
+}
+void GlibcFree(const AllocatorDispatch*, void* address) {
Primiano Tucci (use gerrit) 2016/08/24 14:11:46 seems like you accidentally copy/pasted this twice
Sigurður Ásgeirsson 2016/09/01 15:18:18 Ooops, I wonder how this even compiled. Fixed :/.
+ __libc_free(address);
+}
+
+size_t GlibcGetSizeEstimate(const AllocatorDispatch*, void* address) {
+ return __libc_usable_size(address);
Primiano Tucci (use gerrit) 2016/08/24 14:11:46 I don't think you need to go down into __libc inte
Primiano Tucci (use gerrit) 2016/08/24 15:28:46 I think you mean __malloc_usable_size here. The n
Sigurður Ásgeirsson 2016/09/01 15:18:18 Thanks, added a TODO.
Sigurður Ásgeirsson 2016/09/01 15:18:18 Done.
+}
} // namespace
const AllocatorDispatch AllocatorDispatch::default_dispatch = {
- &GlibcMalloc, /* alloc_function */
- &GlibcCalloc, /* alloc_zero_initialized_function */
- &GlibcMemalign, /* alloc_aligned_function */
- &GlibcRealloc, /* realloc_function */
- &GlibcFree, /* free_function */
- nullptr, /* next */
+ &GlibcMalloc, /* alloc_function */
+ &GlibcCalloc, /* alloc_zero_initialized_function */
+ &GlibcMemalign, /* alloc_aligned_function */
+ &GlibcRealloc, /* realloc_function */
+ &GlibcFree, /* free_function */
+ &GlibcGetSizeEstimate, /* get_size_estimate_function */
+ nullptr, /* next */
};

Powered by Google App Engine
This is Rietveld 408576698