aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lfalloc
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-24 20:07:06 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-24 20:07:06 +0300
commitd7b7178997d5f37bd21b7eae2f8432ce869cb40e (patch)
tree4cf13441141acef714178a1c78675a1f157ecc00 /library/cpp/lfalloc
parenta6a11e07f1f3d6a0151440a67319641ece7e068a (diff)
downloadydb-d7b7178997d5f37bd21b7eae2f8432ce869cb40e.tar.gz
intermediate changes
ref:683903717983aa6a9b3c7bb18933a3e48586b904
Diffstat (limited to 'library/cpp/lfalloc')
-rw-r--r--library/cpp/lfalloc/lf_allocX64.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h
index fd2a906d6f..c9150b99ba 100644
--- a/library/cpp/lfalloc/lf_allocX64.h
+++ b/library/cpp/lfalloc/lf_allocX64.h
@@ -1320,7 +1320,12 @@ static inline void* GetAllocPtr(TAllocHeader* p) {
}
static inline TAllocHeader* GetAllocHeader(void* p) {
- auto* header = ((TAllocHeader*)p) - 1;
+ return ((TAllocHeader*)p) - 1;
+}
+
+// if present, uses the fake header stored by LFPosixMemalign() to retrieve the original header.
+static inline TAllocHeader* GetOrigAllocHeader(void* p) {
+ auto* header = GetAllocHeader(p);
if (header->Tag == DBG_ALLOC_ALIGNED_TAG) {
return (TAllocHeader*)header->Size;
}
@@ -1585,7 +1590,7 @@ static Y_FORCE_INLINE void LFFree(void* p) {
#if defined(LFALLOC_DBG)
if (p == nullptr)
return;
- p = GetAllocHeader(p);
+ p = GetOrigAllocHeader(p);
#endif
uintptr_t chkOffset = ((char*)p - ALLOC_START) - 1ll;
@@ -1648,7 +1653,7 @@ static size_t LFGetSize(const void* p) {
#if defined(LFALLOC_DBG)
if (p == nullptr)
return 0;
- return GetAllocHeader(const_cast<void*>(p))->Size;
+ return GetOrigAllocHeader(const_cast<void*>(p))->Size;
#endif
uintptr_t chkOffset = ((const char*)p - ALLOC_START);