Mesa (master): ralloc: add DECLARE_RZALLOC_CXX_OPERATORS
Marek Olšák
mareko at kemper.freedesktop.org
Mon Oct 31 11:26:38 UTC 2016
Module: Mesa
Branch: master
Commit: 9454f7c0ef55a9357473e451f0f59432c9438f01
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9454f7c0ef55a9357473e451f0f59432c9438f01
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Oct 7 02:16:12 2016 +0200
ralloc: add DECLARE_RZALLOC_CXX_OPERATORS
Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net>
Tested-by: Edmondo Tommasina <edmondo.tommasina at gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
Reviewed-by: Kenneth Graunke <kenneth at whiteacpe.org>
---
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
@@ -421,7 +421,7 @@ bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args);
*
* 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) \
{ \
@@ -430,7 +430,7 @@ private: \
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); \
@@ -448,5 +448,10 @@ public: \
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
More information about the mesa-commit
mailing list