447880 {
447881 lock_guard<mutex> guard(lock);
447882 D_ASSERT(!head || head->position <= head->capacity);
447883 BufferHandle handle;
447884 if (!head || head->position + alloc_len > head->capacity) {
447885
447886 auto block_size = buffer_manager.GetBlockSize();
447887 ;
447889 if (!head && alloc_len <= 4096) {
447890 capacity = 4096;
447891 } else {
447892 capacity = block_size;
447893 }
447894 if (capacity < alloc_len) {
447895 capacity = NextPowerOfTwo(alloc_len);
447896 }
447897 auto entry = make_uniq<UndoBufferEntry>(buffer_manager);
447898 if (capacity < block_size) {
447899 entry->block = buffer_manager.RegisterSmallMemory(MemoryTag::TRANSACTION, capacity);
447900 handle = buffer_manager.Pin(entry->block);
447901 } else {
447902 handle = buffer_manager.Allocate(MemoryTag::TRANSACTION, capacity, false);
447903 entry->block = handle.GetBlockHandle();
447904 }
447905 entry->capacity = capacity;
447906 entry->position = 0;
447907
447908 if (head) {
447909 head->prev = entry.get();
447910 entry->next = std::move(head);
447911 } else {
447912 tail = entry.get();
447913 }
447914 head = std::move(entry);
447915 } else {
447916 handle = buffer_manager.Pin(head->block);
447917 }
447918 idx_t current_position = head->position;
447919 head->position += alloc_len;
447920 return UndoBufferReference(*head, std::move(handle), current_position);
447921}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237