From b080de4420648a49acad4950868522075c6f84c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 26 Nov 2012 19:45:54 +0000 Subject: [PATCH] d3dretrace: Prevent ScopedAllocator::alloc clash. D3D8 and D3D9 have different definitions of the D3DPRESENT_PARAMETERS. This happens with other types, so the only solution is to stop using templates here. --- retrace/retrace.hpp | 14 ++++---------- retrace/retrace.py | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/retrace/retrace.hpp b/retrace/retrace.hpp index ab1ba5c..cc77029 100644 --- a/retrace/retrace.hpp +++ b/retrace/retrace.hpp @@ -60,6 +60,7 @@ private: uintptr_t next; public: + inline ScopedAllocator() : next(0) { } @@ -81,21 +82,14 @@ public: return static_cast(&buf[1]); } - template< class T > - inline T * - alloc(size_t n = 1) { - return static_cast(alloc(sizeof(T) * n)); - } - /** * Allocate an array with the same dimensions as the specified value. */ - template< class T > - inline T * - alloc(const trace::Value *value) { + inline void * + alloc(const trace::Value *value, size_t size) { const trace::Array *array = dynamic_cast(value); if (array) { - return alloc(array->size()); + return alloc(array->size() * size); } const trace::Null *null = dynamic_cast(value); if (null) { diff --git a/retrace/retrace.py b/retrace/retrace.py index 1e39d42..cd5ef1d 100644 --- a/retrace/retrace.py +++ b/retrace/retrace.py @@ -66,10 +66,10 @@ class ValueAllocator(stdapi.Visitor): pass def visitArray(self, array, lvalue, rvalue): - print ' %s = _allocator.alloc<%s>(&%s);' % (lvalue, array.type, rvalue) + print ' %s = static_cast<%s *>(_allocator.alloc(&%s, sizeof *%s));' % (lvalue, array.type, rvalue, lvalue) def visitPointer(self, pointer, lvalue, rvalue): - print ' %s = _allocator.alloc<%s>(&%s);' % (lvalue, pointer.type, rvalue) + print ' %s = static_cast<%s *>(_allocator.alloc(&%s, sizeof *%s));' % (lvalue, pointer.type, rvalue, lvalue) def visitIntPointer(self, pointer, lvalue, rvalue): pass -- 2.43.0