summaryrefslogtreecommitdiff
path: root/src/system-alloc.cc
diff options
context:
space:
mode:
authorAliaksey Kandratsenka <alk@tut.by>2013-11-16 14:01:38 -0800
committerAliaksey Kandratsenka <alk@tut.by>2013-11-16 16:00:31 -0800
commit925bbaea76b91bd307634908cfd6902f99804544 (patch)
treef2f83934363a5d8bd11e57b74e1650f9c41ba0af /src/system-alloc.cc
parentf216317a879e972ceafe77e61b2d66fd5f29922e (diff)
downloadgperftools-925bbaea76b91bd307634908cfd6902f99804544.tar.gz
actually check result of CheckAddressBits
Previously call to CheckAddressBits was made but nothing was done to it's result. I've also make sure that actual size is used in checks and in bumping up of TCMalloc_SystemTaken.
Diffstat (limited to 'src/system-alloc.cc')
-rw-r--r--src/system-alloc.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/system-alloc.cc b/src/system-alloc.cc
index 52e1094..e09e072 100644
--- a/src/system-alloc.cc
+++ b/src/system-alloc.cc
@@ -495,17 +495,17 @@ void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size,
// Enforce minimum alignment
if (alignment < sizeof(MemoryAligner)) alignment = sizeof(MemoryAligner);
+ size_t actual_size_storage;
+ if (actual_size == NULL) {
+ actual_size = &actual_size_storage;
+ }
+
void* result = sys_alloc->Alloc(size, actual_size, alignment);
if (result != NULL) {
- if (actual_size) {
+ CHECK_CONDITION(
CheckAddressBits<kAddressBits>(
- reinterpret_cast<uintptr_t>(result) + *actual_size - 1);
- TCMalloc_SystemTaken += *actual_size;
- } else {
- CheckAddressBits<kAddressBits>(
- reinterpret_cast<uintptr_t>(result) + size - 1);
- TCMalloc_SystemTaken += size;
- }
+ reinterpret_cast<uintptr_t>(result) + *actual_size - 1));
+ TCMalloc_SystemTaken += *actual_size;
}
return result;
}