Mesa (master): i965: Initialize all member variables of cfg_t on construction.

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


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

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Fri Sep 20 16:29:48 2013 -0700

i965: Initialize all member variables of cfg_t on construction.

The cfg_t object relies on the memory allocator zeroing out its
contents before it's initialized, which is quite an unusual practice
in the C++ world 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.  Initialize all fields from the
constructor and stop using the zeroing allocator.

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

---

 src/mesa/drivers/dri/i965/brw_cfg.cpp |    1 +
 src/mesa/drivers/dri/i965/brw_cfg.h   |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp
index 02ae37e..33097eb 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp
@@ -82,6 +82,7 @@ cfg_t::create(void *parent_mem_ctx, exec_list *instructions)
 {
    mem_ctx = ralloc_context(parent_mem_ctx);
    block_list.make_empty();
+   blocks = NULL;
    num_blocks = 0;
    ip = 0;
    cur = NULL;
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h
index 505a5cf..ec5a3a0 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.h
+++ b/src/mesa/drivers/dri/i965/brw_cfg.h
@@ -60,7 +60,7 @@ public:
 
 class cfg_t {
 public:
-   DECLARE_RZALLOC_CXX_OPERATORS(cfg_t)
+   DECLARE_RALLOC_CXX_OPERATORS(cfg_t)
 
    cfg_t(backend_visitor *v);
    cfg_t(void *mem_ctx, exec_list *instructions);




More information about the mesa-commit mailing list