diff options
Diffstat (limited to 'standalone/allocator_common.h')
-rw-r--r-- | standalone/allocator_common.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/standalone/allocator_common.h b/standalone/allocator_common.h index 95f4776ac59..2b77516ad11 100644 --- a/standalone/allocator_common.h +++ b/standalone/allocator_common.h @@ -40,6 +40,7 @@ template <class SizeClassAllocator> struct TransferBatch { B->Count = static_cast<u16>(B->Count - N); } void clear() { Count = 0; } + bool empty() { return Count == 0; } void add(CompactPtrT P) { DCHECK_LT(Count, MaxNumCached); Batch[Count++] = P; @@ -48,6 +49,12 @@ template <class SizeClassAllocator> struct TransferBatch { memcpy(Array, Batch, sizeof(Batch[0]) * Count); clear(); } + + void moveNToArray(CompactPtrT *Array, u16 N) { + DCHECK_LE(N, Count); + memcpy(Array, Batch + Count - N, sizeof(Batch[0]) * N); + Count = static_cast<u16>(Count - N); + } u16 getCount() const { return Count; } bool isEmpty() const { return Count == 0U; } CompactPtrT get(u16 I) const { |