aboutsummaryrefslogtreecommitdiffstats
path: root/parser/rxx_allocator.h
diff options
context:
space:
mode:
Diffstat (limited to 'parser/rxx_allocator.h')
-rw-r--r--parser/rxx_allocator.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/parser/rxx_allocator.h b/parser/rxx_allocator.h
index f0159e936..8325edbdf 100644
--- a/parser/rxx_allocator.h
+++ b/parser/rxx_allocator.h
@@ -24,6 +24,18 @@
#include <string.h>
#include <memory>
+// Stride calculation
+template <typename T>
+struct Tchar {
+ T t;
+ char c;
+};
+
+#define strideof(T) \
+ ((sizeof(Tchar<T>) > sizeof(T)) ? \
+ sizeof(Tchar<T>)-sizeof(T) : sizeof(T))
+
+
/**The allocator which uses fixed size blocks for allocation of its elements.
Block size is currently 64k, allocated space is not reclaimed,
if the size of the element being allocated extends the amount of free
@@ -93,6 +105,12 @@ public:
return p;
}
+ pointer allocate(size_type __n, size_type stride, const void* = 0) {
+ if (reinterpret_cast<size_type>(_M_current_block + _M_current_index) % stride > 0)
+ _M_current_index += stride - reinterpret_cast<size_type>(_M_current_block + _M_current_index) % stride;
+ return allocate(__n);
+ }
+
/**Deallocate does nothing in this implementation.*/
void deallocate(pointer /*__p*/, size_type /*__n*/) {}