You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//! Constructor. TODO: remove, alloc can fail, should be a static create method instead!
39
35
/** @param sizeInBytes Size in bytes. If `dat` argument is present, it denotes size of data pointed by `dat`, otherwise - size of data to be allocated.
// FIXME: ONLY SWAP FOR COMPATIBLE ALLOCATORS! OTHERWISE MEMCPY!
115
109
if (willBeRestoredFrom(_other))
116
110
std::swap(data, other->data);
117
111
}
118
112
113
+
// REMEMBER TO CALL FROM DTOR!
114
+
// TODO: idea, make the `ICPUBuffer` an ADT, and use the default allocator CCPUBuffer instead for consistency
115
+
// TODO: idea make a macro for overriding all `delete` operators of a class to enforce a finalizer that runs in reverse order to destructors (to allow polymorphic cleanups)
116
+
virtualvoidfreeData()
117
+
{
118
+
if (data)
119
+
_NBL_ALIGNED_FREE(data);
120
+
data = nullptr;
121
+
m_creationParams.size = 0ull;
122
+
}
123
+
119
124
void* data;
120
125
};
121
126
@@ -140,42 +145,37 @@ using CDummyCPUBuffer = CCustomAllocatorCPUBuffer<core::null_allocator<uint8_t>,
140
145
*/
141
146
142
147
template<typename Allocator>
143
-
classCCustomAllocatorCPUBuffer<Allocator,true> : public ICPUBuffer
148
+
classCCustomAllocatorCPUBuffer<Allocator,true> : public ICPUBuffer
144
149
{
145
150
static_assert(sizeof(typename Allocator::value_type) == 1u, "Allocator::value_type must be of size 1");
0 commit comments