nir: Allocate nir_tex_instr::sources out of the instruction itself.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 28 Mar 2015 07:02:37 +0000 (00:02 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 2 Apr 2015 21:20:03 +0000 (14:20 -0700)
The lifetime of the sources array needs to be match the nir_tex_instr
itself.  So, allocate it using the instruction itself as the context.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/glsl/nir/nir.c

index 73d3008a0b330514538f27effd44b2a0a64b0f8d..5f86ecaa202949d0b86774379a99d8be83df133c 100644 (file)
@@ -460,7 +460,7 @@ nir_tex_instr_create(void *mem_ctx, unsigned num_srcs)
    dest_init(&instr->dest);
 
    instr->num_srcs = num_srcs;
-   instr->src = ralloc_array(mem_ctx, nir_tex_src, num_srcs);
+   instr->src = ralloc_array(instr, nir_tex_src, num_srcs);
    for (unsigned i = 0; i < num_srcs; i++)
       src_init(&instr->src[i].src);