Mesa (master): ralloc: Remove the rzalloc-based new/ delete operator definition macro.

Francisco Jerez currojerez at kemper.freedesktop.org
Wed Oct 2 00:42:34 UTC 2013


Module: Mesa
Branch: master
Commit: ef8cc3e51f7c9c6134a76e299908c74e02800ae3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef8cc3e51f7c9c6134a76e299908c74e02800ae3

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Tue Oct  1 17:00:32 2013 -0700

ralloc: Remove the rzalloc-based new/delete operator definition macro.

Using it encourages the (IMHO worrying) practice of leaving member
variables uninitialized in constructor definitions.  This macro
shouldn't be necessary anymore after the last patch series fixing all
its users to initialize all member variables from the class
constructor.  Remove it.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/glsl/ralloc.h |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/glsl/ralloc.h b/src/glsl/ralloc.h
index 799d3a9..31682d5 100644
--- a/src/glsl/ralloc.h
+++ b/src/glsl/ralloc.h
@@ -404,10 +404,20 @@ bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args);
 } /* end of extern "C" */
 #endif
 
-#define _RALLOC_OPS(ALLOC, TYPE)                                         \
+/**
+ * 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)                               \
    static void* operator new(size_t size, void *mem_ctx)                 \
    {                                                                     \
-      void *p = ALLOC(mem_ctx, size);                                    \
+      void *p = ralloc_size(mem_ctx, size);                              \
       assert(p != NULL);                                                 \
       return p;                                                          \
    }                                                                     \
@@ -417,17 +427,5 @@ bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args);
       ralloc_free(p);                                                    \
    }
 
-/**
- * Declare C++ new and delete operators which use ralloc.
- *
- * Placing one of these macros 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 or rzalloc.
- */
-#define DECLARE_RALLOC_CXX_OPERATORS(TYPE)  _RALLOC_OPS(ralloc_size,  TYPE)
-#define DECLARE_RZALLOC_CXX_OPERATORS(TYPE) _RALLOC_OPS(rzalloc_size, TYPE)
 
 #endif




More information about the mesa-commit mailing list