[Mesa-dev] [PATCH 03/11] glsl: Switch ast_node to the non-zeroing allocator.

Francisco Jerez currojerez at riseup.net
Fri Sep 20 21:51:41 PDT 2013


All member variables of ast_node are already being initialized from
its constructor, but some of its derived classes were leaving members
uninitialized -- Fix them.

Using rzalloc makes it more likely that we will start relying on the
allocator to zero out all memory if the class is ever extended with
new member variables.  That's bad because it ties objects to some
specific allocation scheme, and gives unpredictable results when an
object is created with a different allocator -- Stack allocation,
array allocation, or aggregation inside a different object are some of
the useful possibilities that come to my mind.
---
 src/glsl/ast.h                  | 10 +++++++++-
 src/glsl/glsl_parser_extras.cpp |  3 ++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index c3361a1..f278fe5 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -49,7 +49,7 @@ struct YYLTYPE;
  */
 class ast_node {
 public:
-   DECLARE_RZALLOC_CXX_OPERATORS(ast_node);
+   DECLARE_RALLOC_CXX_OPERATORS(ast_node);
 
    /**
     * Print an AST node in something approximating the original GLSL code
@@ -576,6 +576,10 @@ public:
    virtual void print(void) const;
    bool has_qualifiers() const;
 
+   ast_fully_specified_type() : qualifier(), specifier()
+   {
+   }
+
    const struct glsl_type *glsl_type(const char **name,
 				     struct _mesa_glsl_parse_state *state)
       const;
@@ -859,6 +863,10 @@ public:
 
 class ast_function_definition : public ast_node {
 public:
+   ast_function_definition() : prototype(), body()
+   {
+   }
+
    virtual void print(void) const;
 
    virtual ir_rvalue *hir(exec_list *instructions,
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 772933f..bf2909c 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1058,7 +1058,8 @@ ast_expression::print(void) const
 ast_expression::ast_expression(int oper,
 			       ast_expression *ex0,
 			       ast_expression *ex1,
-			       ast_expression *ex2)
+			       ast_expression *ex2) :
+   primary_expression()
 {
    this->oper = ast_operators(oper);
    this->subexpressions[0] = ex0;
-- 
1.8.3.4



More information about the mesa-dev mailing list