From: Marek Olšák <marek.ol...@amd.com> --- src/util/ralloc.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/util/ralloc.h b/src/util/ralloc.h index 7587e11..d74a398 100644 --- a/src/util/ralloc.h +++ b/src/util/ralloc.h @@ -414,39 +414,44 @@ bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args); /** * Declare C++ new and delete operators which use ralloc. * * Placing this macro in the body of a class makes it possible to do: * * TYPE *var = new(mem_ctx) TYPE(...); * delete var; * * which is more idiomatic in C++ than calling ralloc. */ -#define DECLARE_RALLOC_CXX_OPERATORS(TYPE) \ +#define DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(TYPE, ALLOC_FUNC) \ private: \ static void _ralloc_destructor(void *p) \ { \ reinterpret_cast<TYPE *>(p)->~TYPE(); \ } \ public: \ static void* operator new(size_t size, void *mem_ctx) \ { \ - void *p = ralloc_size(mem_ctx, size); \ + void *p = ALLOC_FUNC(mem_ctx, size); \ assert(p != NULL); \ if (!HAS_TRIVIAL_DESTRUCTOR(TYPE)) \ ralloc_set_destructor(p, _ralloc_destructor); \ return p; \ } \ \ static void operator delete(void *p) \ { \ /* The object's destructor is guaranteed to have already been \ * called by the delete operator at this point -- Make sure it's \ * not called again. \ */ \ if (!HAS_TRIVIAL_DESTRUCTOR(TYPE)) \ ralloc_set_destructor(p, NULL); \ ralloc_free(p); \ } +#define DECLARE_RALLOC_CXX_OPERATORS(type) \ + DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, ralloc_size) + +#define DECLARE_RZALLOC_CXX_OPERATORS(type) \ + DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, rzalloc_size) #endif -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev