summaryrefslogtreecommitdiffstats
path: root/include/framework/structure
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2024-01-15 17:23:57 -0500
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2024-01-15 17:23:57 -0500
commit2117935e85412f3733ee0bcb1830c7fd0b129b29 (patch)
tree303d4482263f25a45b157fef82217084db20be8d /include/framework/structure
parent0a9e79416df03a9e0a3d2cf171cf90028a644d6d (diff)
downloaddynamic-extension-2117935e85412f3733ee0bcb1830c7fd0b129b29.tar.gz
Concurrency testing and bug fixes
Diffstat (limited to 'include/framework/structure')
-rw-r--r--include/framework/structure/BufferView.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/framework/structure/BufferView.h b/include/framework/structure/BufferView.h
index c751786..099b7a2 100644
--- a/include/framework/structure/BufferView.h
+++ b/include/framework/structure/BufferView.h
@@ -105,7 +105,15 @@ public:
}
void copy_to_buffer(psudb::byte *buffer) {
- memcpy(buffer, (std::byte*) (m_data + (m_head % m_cap)), get_record_count() * sizeof(Wrapped<R>));
+ /* check if the region to be copied circles back to start. If so, do it in two steps */
+ if ((m_head % m_cap) + get_record_count() > m_cap) {
+ size_t split_idx = m_cap - (m_head % m_cap);
+
+ memcpy(buffer, (std::byte*) (m_data + (m_head % m_cap)), split_idx* sizeof(Wrapped<R>));
+ memcpy(buffer + split_idx, (std::byte*) m_data, (get_record_count() - split_idx) * sizeof(Wrapped<R>));
+ } else {
+ memcpy(buffer, (std::byte*) (m_data + (m_head % m_cap)), get_record_count() * sizeof(Wrapped<R>));
+ }
}
size_t get_tail() {