Mesa (master): zink: use ralloc for plain malloc-calls

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 17 17:43:22 UTC 2020


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Fri Jul 17 18:55:53 2020 +0200

zink: use ralloc for plain malloc-calls

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5954>

---

 src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 44eade4e25a..11145ed4257 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -2274,18 +2274,21 @@ nir_to_spirv(struct nir_shader *s, const struct pipe_stream_output_info *so_info
    nir_function_impl *entry = nir_shader_get_entrypoint(s);
    nir_metadata_require(entry, nir_metadata_block_index);
 
-   ctx.defs = (SpvId *)malloc(sizeof(SpvId) * entry->ssa_alloc);
+   ctx.defs = ralloc_array_size(ctx.mem_ctx,
+                                sizeof(SpvId), entry->ssa_alloc);
    if (!ctx.defs)
       goto fail;
    ctx.num_defs = entry->ssa_alloc;
 
    nir_index_local_regs(entry);
-   ctx.regs = malloc(sizeof(SpvId) * entry->reg_alloc);
+   ctx.regs = ralloc_array_size(ctx.mem_ctx,
+                                sizeof(SpvId), entry->reg_alloc);
    if (!ctx.regs)
       goto fail;
    ctx.num_regs = entry->reg_alloc;
 
-   SpvId *block_ids = (SpvId *)malloc(sizeof(SpvId) * entry->num_blocks);
+   SpvId *block_ids = ralloc_array_size(ctx.mem_ctx,
+                                        sizeof(SpvId), entry->num_blocks);
    if (!block_ids)
       goto fail;
 
@@ -2310,8 +2313,6 @@ nir_to_spirv(struct nir_shader *s, const struct pipe_stream_output_info *so_info
 
    emit_cf_list(&ctx, &entry->body);
 
-   free(ctx.defs);
-
    if (so_info)
       emit_so_outputs(&ctx, so_info, local_so_info);
 



More information about the mesa-commit mailing list