mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
dbms: fixed error with memory tracking [#METR-16433].
This commit is contained in:
parent
51be2693ee
commit
97782b4855
@ -151,20 +151,18 @@ public:
|
||||
|
||||
void * realloc(void * buf, size_t old_size, size_t new_size)
|
||||
{
|
||||
/// Было в stack_memory, там и останется.
|
||||
if (new_size <= N)
|
||||
return buf;
|
||||
|
||||
/// Уже не помещалось в stack_memory.
|
||||
if (old_size > N)
|
||||
return HashTableAllocator::realloc(buf, old_size, new_size);
|
||||
|
||||
buf = ::malloc(new_size);
|
||||
if (nullptr == buf)
|
||||
DB::throwFromErrno("HashTableAllocator: Cannot malloc.", DB::ErrorCodes::CANNOT_ALLOCATE_MEMORY);
|
||||
|
||||
memcpy(buf, stack_memory, old_size);
|
||||
memset(reinterpret_cast<char *>(buf) + old_size, 0, new_size - old_size);
|
||||
|
||||
return buf;
|
||||
/// Было в stack_memory, но теперь не помещается.
|
||||
void * new_buf = HashTableAllocator::alloc(new_size);
|
||||
memcpy(new_buf, buf, old_size);
|
||||
return new_buf;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user