Skip to content

Fix rebinding an allocator to the same type should result in the original allocator #1023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions ydb/library/yql/minikql/mkql_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,15 @@ inline void* MKQLAllocWithSize(size_t sz, const EMemorySubPool mPool) {
}

inline void MKQLFreeWithSize(const void* mem, size_t sz, const EMemorySubPool mPool) noexcept {
return MKQLFreeFastWithSize(mem, sz, TlsAllocState, mPool);
MKQLFreeFastWithSize(mem, sz, TlsAllocState, mPool);
}

inline void MKQLRegisterObject(NUdf::TBoxedValue* value) noexcept {
return value->Link(TlsAllocState->GetRoot());
value->Link(TlsAllocState->GetRoot());
}

inline void MKQLUnregisterObject(NUdf::TBoxedValue* value) noexcept {
return value->Unlink();
value->Unlink();
}

template <const EMemorySubPool MemoryPoolExt = EMemorySubPool::Default>
Expand Down Expand Up @@ -426,7 +426,7 @@ T* AllocateOn(TAllocState* state, Args&&... args)
static_assert(std::is_base_of<TWithMiniKQLAlloc<T::MemoryPool>, T>::value, "Class must inherit TWithMiniKQLAlloc.");
}

template <typename Type, enum EMemorySubPool MemoryPool = EMemorySubPool::Default>
template <typename Type, EMemorySubPool MemoryPool = EMemorySubPool::Default>
struct TMKQLAllocator
{
typedef Type value_type;
Expand All @@ -440,10 +440,10 @@ struct TMKQLAllocator
TMKQLAllocator() noexcept = default;
~TMKQLAllocator() noexcept = default;

template<typename U> TMKQLAllocator(const TMKQLAllocator<U>&) noexcept {}
template<typename U> struct rebind { typedef TMKQLAllocator<U> other; };
template<typename U> bool operator==(const TMKQLAllocator<U>&) const { return true; }
template<typename U> bool operator!=(const TMKQLAllocator<U>&) const { return false; }
template<typename U> TMKQLAllocator(const TMKQLAllocator<U, MemoryPool>&) noexcept {}
template<typename U> struct rebind { typedef TMKQLAllocator<U, MemoryPool> other; };
template<typename U> bool operator==(const TMKQLAllocator<U, MemoryPool>&) const { return true; }
template<typename U> bool operator!=(const TMKQLAllocator<U, MemoryPool>&) const { return false; }

static pointer allocate(size_type n, const void* = nullptr)
{
Expand All @@ -452,7 +452,7 @@ struct TMKQLAllocator

static void deallocate(const_pointer p, size_type n) noexcept
{
return MKQLFreeWithSize(p, n * sizeof(value_type), MemoryPool);
MKQLFreeWithSize(p, n * sizeof(value_type), MemoryPool);
}
};

Expand Down Expand Up @@ -683,7 +683,7 @@ class TPagedList

inline void TBoxedValueWithFree::operator delete(void *mem) noexcept {
auto size = ((TMkqlPAllocHeader*)mem)->Size + sizeof(TMkqlPAllocHeader);
return MKQLFreeWithSize(mem, size, EMemorySubPool::Default);
MKQLFreeWithSize(mem, size, EMemorySubPool::Default);
}

} // NMiniKQL
Expand Down