treewide: don't check before free
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

This was something that came up in the slop MR. Not sure it's actually a
good idea or not but kind of curious what people think, given we have a
sound tool (Coccinelle) to do the transform. Saves a redundant branch
but means extra noninlined function calls.. likely no actual perf impact
but saves some code.

Via Coccinelle patches:

    @@
    expression ptr;
    @@

    -if (ptr) {
    -free(ptr);
    -}
    +free(ptr);

    @@
    expression ptr;
    @@

    -if (ptr) {
    -FREE(ptr);
    -}
    +FREE(ptr);

    @@
    expression ptr;
    @@

    -if (ptr) {
    -ralloc_free(ptr);
    -}
    +ralloc_free(ptr);

    @@
    expression ptr;
    @@

    -if (ptr != NULL) {
    -free(ptr);
    -}
    -
    +free(ptr);

    @@
    expression ptr;
    @@

    -if (ptr != NULL) {
    -FREE(ptr);
    -}
    -
    +FREE(ptr);

    @@
    expression ptr;
    @@

    -if (ptr != NULL) {
    -ralloc_free(ptr);
    -}
    -
    +ralloc_free(ptr);

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> [v3d]
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> [venus]
Reviewed-by: Frank Binns <frank.binns@imgtec.com> [powervr]
Reviewed-by: Janne Grunau <j@jannau.net> [asahi]
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> [radv]
Reviewed-by: Job Noorman <jnoorman@igalia.com> [ir3]
Acked-by: Marek Olšák <maraeo@gmail.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Acked-by: Job Noorman <jnoorman@igalia.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37892>
This commit is contained in:
Alyssa Rosenzweig 2025-10-15 11:25:23 -04:00 committed by Marge Bot
parent 543c9be87a
commit 84d8e6824b
53 changed files with 84 additions and 183 deletions

View file

@ -2997,8 +2997,7 @@ radv_graphics_pipeline_state_finish(struct radv_device *device, struct radv_grap
for (uint32_t i = 0; i < MESA_VULKAN_SHADER_STAGES; i++)
ralloc_free(gfx_state->stages[i].nir);
if (gfx_state->stages[MESA_SHADER_GEOMETRY].gs_copy_shader)
ralloc_free(gfx_state->stages[MESA_SHADER_GEOMETRY].gs_copy_shader);
ralloc_free(gfx_state->stages[MESA_SHADER_GEOMETRY].gs_copy_shader);
free(gfx_state->stages);
}

View file

@ -167,8 +167,7 @@ radv_shader_object_init_graphics(struct radv_shader_object *shader_obj, struct r
binary = binaries[stage];
ralloc_free(stages[stage].nir);
if (stages[MESA_SHADER_GEOMETRY].gs_copy_shader)
ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader);
ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader);
shader_obj->shader = shader;
shader_obj->binary = binary;
@ -196,8 +195,7 @@ radv_shader_object_init_graphics(struct radv_shader_object *shader_obj, struct r
binary = binaries[stage];
ralloc_free(stages[stage].nir);
if (stages[MESA_SHADER_GEOMETRY].gs_copy_shader)
ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader);
ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader);
if (stage == MESA_SHADER_VERTEX) {
if (next_stage == MESA_SHADER_TESS_CTRL) {
@ -549,8 +547,7 @@ radv_shader_object_create_linked(VkDevice _device, uint32_t createInfoCount, con
pShaders[i] = radv_shader_object_to_handle(shader_obj);
}
if (stages[MESA_SHADER_GEOMETRY].gs_copy_shader)
ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader);
ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader);
return VK_SUCCESS;
}

View file

@ -46,11 +46,8 @@ agx_compute_liveness(agx_context *ctx)
unsigned words = BITSET_WORDS(ctx->alloc);
agx_foreach_block(ctx, block) {
if (block->live_in)
ralloc_free(block->live_in);
if (block->live_out)
ralloc_free(block->live_out);
ralloc_free(block->live_in);
ralloc_free(block->live_out);
block->live_in = rzalloc_array(block, BITSET_WORD, words);
block->live_out = rzalloc_array(block, BITSET_WORD, words);

View file

@ -123,8 +123,7 @@ v3dv_destroy_pipeline(struct v3dv_pipeline *pipeline,
pipeline->default_attribute_values = NULL;
}
if (pipeline->executables.mem_ctx)
ralloc_free(pipeline->executables.mem_ctx);
ralloc_free(pipeline->executables.mem_ctx);
if (pipeline->layout)
v3dv_pipeline_layout_unref(device, pipeline->layout, pAllocator);

View file

@ -338,8 +338,7 @@ nir_free_output_dependencies(nir_output_deps *deps)
{
for (unsigned i = 0; i < ARRAY_SIZE(deps->output); i++) {
assert(!!deps->output[i].instr_list == !!deps->output[i].num_instr);
if (deps->output[i].instr_list)
free(deps->output[i].instr_list);
free(deps->output[i].instr_list);
}
}

View file

@ -1382,8 +1382,7 @@ get_loop_info(loop_info_state *state, nir_function_impl *impl)
static void
initialize_loop_info(nir_loop *loop)
{
if (loop->info)
ralloc_free(loop->info);
ralloc_free(loop->info);
loop->info = rzalloc(loop, nir_loop_info);
loop->info->induction_vars = _mesa_pointer_hash_table_create(loop->info);

View file

@ -190,8 +190,7 @@ fd_rd_output_init(struct fd_rd_output *output, const char* output_name)
void
fd_rd_output_fini(struct fd_rd_output *output)
{
if (output->name != NULL)
free(output->name);
free(output->name);
if (output->file != NULL) {
assert(output->combine);

View file

@ -608,6 +608,5 @@ ir3_lower_copies(struct ir3_shader_variant *v)
}
}
if (copies)
ralloc_free(copies);
ralloc_free(copies);
}

View file

@ -1498,8 +1498,7 @@ ir3_ra_shared(struct ir3_shader_variant *v, struct ir3_liveness **live_ptr)
lower_pcopy(v->ir, &ctx);
for (unsigned i = 0; i < live->block_count; i++) {
if (ctx.blocks[i].live_out)
ralloc_free(ctx.blocks[i].live_out);
ralloc_free(ctx.blocks[i].live_out);
}
ralloc_free(ctx.intervals);

View file

@ -3121,9 +3121,7 @@ tu_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator)
tu_cs_finish(&device->sub_cs);
if (device->perfcntrs_pass_cs_entries) {
free(device->perfcntrs_pass_cs_entries);
}
free(device->perfcntrs_pass_cs_entries);
if (device->dbg_cmdbuf_stomp_cs) {
tu_cs_finish(device->dbg_cmdbuf_stomp_cs);

View file

@ -2252,8 +2252,7 @@ draw_llvm_destroy_variant(struct draw_llvm_variant *variant)
variant->shader->variants_cached--;
list_del(&variant->list_item_global.list);
llvm->nr_variants--;
if(variant->function_name)
FREE(variant->function_name);
FREE(variant->function_name);
FREE(variant);
}
@ -2582,8 +2581,7 @@ draw_gs_llvm_destroy_variant(struct draw_gs_llvm_variant *variant)
variant->shader->variants_cached--;
list_del(&variant->list_item_global.list);
llvm->nr_gs_variants--;
if(variant->function_name)
FREE(variant->function_name);
FREE(variant->function_name);
FREE(variant);
}
@ -3257,8 +3255,7 @@ draw_tcs_llvm_destroy_variant(struct draw_tcs_llvm_variant *variant)
variant->shader->variants_cached--;
list_del(&variant->list_item_global.list);
llvm->nr_tcs_variants--;
if(variant->function_name)
FREE(variant->function_name);
FREE(variant->function_name);
FREE(variant);
}
@ -3797,8 +3794,7 @@ draw_tes_llvm_destroy_variant(struct draw_tes_llvm_variant *variant)
variant->shader->variants_cached--;
list_del(&variant->list_item_global.list);
llvm->nr_tes_variants--;
if(variant->function_name)
FREE(variant->function_name);
FREE(variant->function_name);
FREE(variant);
}

View file

@ -730,9 +730,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
FREE(gs_vert_info[i].verts);
}
if (patch_lengths) {
FREE(patch_lengths);
}
FREE(patch_lengths);
if (free_prim_info) {
FREE(tes_elts_out);

View file

@ -76,8 +76,7 @@ vs_llvm_delete(struct draw_vertex_shader *dvs)
}
assert(shader->variants_cached == 0);
if (dvs->state.ir.nir)
ralloc_free(dvs->state.ir.nir);
ralloc_free(dvs->state.ir.nir);
FREE((void*) dvs->state.tokens);
FREE(dvs);
}

View file

@ -976,8 +976,7 @@ agx_batch_submit(struct agx_context *ctx, struct agx_batch *batch,
util_dynarray_fini(&cmdbuf);
agx_batch_mark_submitted(batch);
if (virt.extres)
free(virt.extres);
free(virt.extres);
/* Record the last syncobj for fence creation */
ctx->syncobj = batch->syncobj;

View file

@ -888,8 +888,7 @@ bool ppir_codegen_prog(ppir_compiler *comp)
}
}
if (comp->prog->shader)
ralloc_free(comp->prog->shader);
ralloc_free(comp->prog->shader);
comp->prog->shader = prog;
comp->prog->state.shader_size = size * sizeof(uint32_t);

View file

@ -527,17 +527,14 @@ static void ppir_regalloc_reset_liveness_info(ppir_compiler *comp)
continue;
list_for_each_entry(ppir_instr, instr, &block->instr_list, list) {
if (instr->live_mask)
ralloc_free(instr->live_mask);
ralloc_free(instr->live_mask);
instr->live_mask = rzalloc_array(comp, uint8_t,
reg_mask_size(comp->reg_num));
if (instr->live_set)
ralloc_free(instr->live_set);
ralloc_free(instr->live_set);
instr->live_set = rzalloc_array(comp, BITSET_WORD, comp->reg_num);
if (instr->live_internal)
ralloc_free(instr->live_internal);
ralloc_free(instr->live_internal);
instr->live_internal = rzalloc_array(comp, BITSET_WORD, comp->reg_num);
}

View file

@ -304,11 +304,9 @@ lima_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *pres)
if (res->scanout)
renderonly_scanout_destroy(res->scanout, screen->ro);
if (res->damage.region)
FREE(res->damage.region);
FREE(res->damage.region);
if (res->index_cache)
FREE(res->index_cache);
FREE(res->index_cache);
FREE(res);
}
@ -778,8 +776,7 @@ lima_transfer_unmap(struct pipe_context *pctx,
struct pipe_box box;
u_box_2d(0, 0, ptrans->box.width, ptrans->box.height, &box);
lima_transfer_flush_region(pctx, ptrans, &box);
if (trans->staging)
free(trans->staging);
free(trans->staging);
if (ptrans->usage & PIPE_MAP_WRITE) {
pan_minmax_cache_invalidate(res->index_cache,
util_format_get_blocksize(res->base.format),

View file

@ -1069,8 +1069,7 @@ llvmpipe_remove_cs_shader_variant(struct llvmpipe_context *lp,
lp->nr_cs_variants--;
lp->nr_cs_instrs -= variant->nr_instrs;
if(variant->function_name)
FREE(variant->function_name);
FREE(variant->function_name);
FREE(variant);
}

View file

@ -4215,12 +4215,9 @@ llvmpipe_destroy_shader_variant(struct llvmpipe_context *lp,
{
gallivm_destroy(variant->gallivm);
lp_fs_reference(lp, &variant->shader, NULL);
if (variant->function_name[RAST_EDGE_TEST])
FREE(variant->function_name[RAST_EDGE_TEST]);
if (variant->function_name[RAST_WHOLE])
FREE(variant->function_name[RAST_WHOLE]);
if (variant->linear_function_name)
FREE(variant->linear_function_name);
FREE(variant->function_name[RAST_EDGE_TEST]);
FREE(variant->function_name[RAST_WHOLE]);
FREE(variant->linear_function_name);
FREE(variant);
}

View file

@ -464,8 +464,7 @@ panfrost_set_resource_label(UNUSED struct pipe_screen *pscreen,
return;
char *old_label = (char *)panfrost_bo_set_label(rsrc->bo, new_label);
if (old_label)
free(old_label);
free(old_label);
}
static bool

View file

@ -158,8 +158,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
{
glsl_type_singleton_init_or_ref();
if (sel->ir_type == PIPE_SHADER_IR_TGSI) {
if (sel->nir)
ralloc_free(sel->nir);
ralloc_free(sel->nir);
if (sel->nir_blob) {
free(sel->nir_blob);
sel->nir_blob = NULL;
@ -311,8 +310,7 @@ void r600_pipe_shader_destroy(struct pipe_context *ctx UNUSED, struct r600_pipe_
r600_bytecode_clear(&shader->shader.bc);
r600_release_command_buffer(&shader->command_buffer);
if (shader->shader.arrays)
free(shader->shader.arrays);
free(shader->shader.arrays);
}
struct r600_shader_ctx {

View file

@ -1157,13 +1157,11 @@ void r600_delete_shader_selector(struct pipe_context *ctx,
if (sel->ir_type == PIPE_SHADER_IR_TGSI) {
free(sel->tokens);
/* We might have converted the TGSI shader to a NIR shader */
if (sel->nir)
ralloc_free(sel->nir);
ralloc_free(sel->nir);
}
else if (sel->ir_type == PIPE_SHADER_IR_NIR)
ralloc_free(sel->nir);
if (sel->nir_blob)
free(sel->nir_blob);
free(sel->nir_blob);
free(sel);
}

View file

@ -3186,10 +3186,8 @@ error:
si_vid_destroy_buffer(&dec->sessionctx);
err:
if (dec->jcs)
FREE(dec->jcs);
if (dec->jctx)
FREE(dec->jctx);
FREE(dec->jcs);
FREE(dec->jctx);
FREE(dec);
return NULL;

View file

@ -370,8 +370,7 @@ void si_destroy_sqtt(struct si_context *sctx)
struct pb_buffer_lean *bo = sctx->sqtt->bo;
radeon_bo_reference(sctx->screen->ws, &bo, NULL);
if (sctx->sqtt->trigger_file)
free(sctx->sqtt->trigger_file);
free(sctx->sqtt->trigger_file);
for (int i = 0; i < ARRAY_SIZE(sctx->sqtt->start_cs); i++) {
sscreen->ws->cs_destroy(sctx->sqtt->start_cs[i]);

View file

@ -891,8 +891,7 @@ si_vpe_processor_destroy(struct pipe_video_codec *codec)
vpe_destroy(&vpeproc->vpe_handle);
if (vpeproc->vpe_build_param) {
if (vpeproc->vpe_build_param->streams)
FREE(vpeproc->vpe_build_param->streams);
FREE(vpeproc->vpe_build_param->streams);
FREE(vpeproc->vpe_build_param);
}
@ -906,14 +905,11 @@ si_vpe_processor_destroy(struct pipe_video_codec *codec)
if (vpeproc->gm_handle)
tm_destroy(&vpeproc->gm_handle);
if (vpeproc->lut_data)
FREE(vpeproc->lut_data);
FREE(vpeproc->lut_data);
if (vpeproc->geometric_scaling_ratios)
FREE(vpeproc->geometric_scaling_ratios);
FREE(vpeproc->geometric_scaling_ratios);
if (vpeproc->lanczos_info)
FREE(vpeproc->lanczos_info);
FREE(vpeproc->lanczos_info);
if (vpeproc->geometric_buf[0])
vpeproc->geometric_buf[0]->destroy(vpeproc->geometric_buf[0]);

View file

@ -1113,10 +1113,8 @@ svga_texture_create(struct pipe_screen *screen,
return &tex->b;
fail:
if (tex->dirty)
FREE(tex->dirty);
if (tex->defined)
FREE(tex->defined);
FREE(tex->dirty);
FREE(tex->defined);
FREE(tex);
fail_notex:
SVGA_STATS_TIME_POP(svgascreen->sws);

View file

@ -192,8 +192,7 @@ transform_dynamic_indexing(struct svga_context *svga,
}
transform_shader->token_key = key;
bind_shader(svga, info->processor, transform_shader);
if (new_tokens)
FREE(new_tokens);
FREE(new_tokens);
}

View file

@ -223,9 +223,7 @@ multisync_set(struct v3d_context *v3d, struct drm_v3d_multi_sync *ms,
out:
fprintf(stderr, "Multisync Set Failed\n");
if (in_syncs) {
free(in_syncs);
}
free(in_syncs);
}
static void

View file

@ -1726,8 +1726,7 @@ static struct pb_buffer_lean *amdgpu_bo_from_handle(struct radeon_winsys *rws,
error:
simple_mtx_unlock(&aws->bo_export_table_lock);
if (bo)
FREE(bo);
FREE(bo);
if (va_handle)
ac_drm_va_range_free(va_handle);
ac_drm_bo_free(aws->dev, result.bo);

View file

@ -947,8 +947,7 @@ static void pvr_physical_device_destroy(struct vk_physical_device *vk_pdevice)
* before freeing or that the freeing functions accept NULL pointers.
*/
if (pdevice->pco_ctx)
ralloc_free(pdevice->pco_ctx);
ralloc_free(pdevice->pco_ctx);
pvr_wsi_finish(pdevice);

View file

@ -1204,9 +1204,9 @@ pvr_CreateComputePipelines(VkDevice _device,
static void pvr_pipeline_destroy_shader_data(pco_data *data)
{
for (unsigned u = 0; u < ARRAY_SIZE(data->common.desc_sets); ++u)
if (data->common.desc_sets[u].bindings)
ralloc_free(data->common.desc_sets[u].bindings);
for (unsigned u = 0; u < ARRAY_SIZE(data->common.desc_sets); ++u) {
ralloc_free(data->common.desc_sets[u].bindings);
}
}
static void

View file

@ -267,8 +267,7 @@ end:
ralloc_free(mem_ctx);
if (devinfo)
free(devinfo);
free(devinfo);
exit(result);
}

View file

@ -375,11 +375,9 @@ end:
if (output)
fclose(output);
if (p)
ralloc_free(p);
ralloc_free(p);
if (devinfo)
free(devinfo);
free(devinfo);
exit(result);
}

View file

@ -866,8 +866,7 @@ main(int argc, char *argv[])
close(1);
wait(NULL);
if (xml_path)
free(xml_path);
free(xml_path);
return EXIT_SUCCESS;
}

View file

@ -866,8 +866,7 @@ _mesa_validate_program_pipeline(struct gl_context* ctx,
/* Release and reset the info log.
*/
if (pipe->InfoLog != NULL)
ralloc_free(pipe->InfoLog);
ralloc_free(pipe->InfoLog);
pipe->InfoLog = NULL;

View file

@ -1614,9 +1614,7 @@ validate_program(struct gl_context *ctx, GLuint program)
shProg->data->Validated = validate_shader_program(shProg, errMsg);
if (!shProg->data->Validated) {
/* update info log */
if (shProg->data->InfoLog) {
ralloc_free(shProg->data->InfoLog);
}
ralloc_free(shProg->data->InfoLog);
shProg->data->InfoLog = ralloc_strdup(shProg->data, errMsg);
}
}

View file

@ -259,22 +259,10 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog)
_mesa_free_parameter_list(prog->Parameters);
}
if (prog->nir) {
ralloc_free(prog->nir);
}
if (prog->sh.BindlessSamplers) {
ralloc_free(prog->sh.BindlessSamplers);
}
if (prog->sh.BindlessImages) {
ralloc_free(prog->sh.BindlessImages);
}
if (prog->driver_cache_blob) {
ralloc_free(prog->driver_cache_blob);
}
ralloc_free(prog->nir);
ralloc_free(prog->sh.BindlessSamplers);
ralloc_free(prog->sh.BindlessImages);
ralloc_free(prog->driver_cache_blob);
ralloc_free(prog);
}

View file

@ -2530,9 +2530,7 @@ yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s)
locp->first_line, locp->first_column, s);
_mesa_set_program_error(state->ctx, locp->position, err_str);
if (err_str) {
free(err_str);
}
free(err_str);
}

View file

@ -72,8 +72,7 @@ void vbo_save_destroy( struct gl_context *ctx )
save->vertex_store = NULL;
}
if (save->copied.buffer)
free(save->copied.buffer);
free(save->copied.buffer);
_mesa_reference_buffer_object(ctx, &save->current_bo, NULL);
}

View file

@ -51,11 +51,8 @@ bi_compute_liveness_ssa(bi_context *ctx)
unsigned words = BITSET_WORDS(ctx->ssa_alloc);
bi_foreach_block(ctx, block) {
if (block->ssa_live_in)
ralloc_free(block->ssa_live_in);
if (block->ssa_live_out)
ralloc_free(block->ssa_live_out);
ralloc_free(block->ssa_live_in);
ralloc_free(block->ssa_live_out);
block->ssa_live_in = rzalloc_array(block, BITSET_WORD, words);
block->ssa_live_out = rzalloc_array(block, BITSET_WORD, words);

View file

@ -255,11 +255,8 @@ bi_compute_liveness_ra(bi_context *ctx)
bi_worklist_init(ctx, &worklist);
bi_foreach_block(ctx, block) {
if (block->live_in)
ralloc_free(block->live_in);
if (block->live_out)
ralloc_free(block->live_out);
ralloc_free(block->live_in);
ralloc_free(block->live_out);
block->live_in = rzalloc_array(block, uint8_t, ctx->ssa_alloc);
block->live_out = rzalloc_array(block, uint8_t, ctx->ssa_alloc);

View file

@ -117,11 +117,9 @@ mir_free_liveness(compiler_context *ctx)
{
mir_foreach_block(ctx, _block) {
midgard_block *block = (midgard_block *)_block;
if (block->live_in)
ralloc_free(block->live_in);
if (block->live_out)
ralloc_free(block->live_out);
ralloc_free(block->live_in);
ralloc_free(block->live_out);
block->live_in = NULL;
block->live_out = NULL;

View file

@ -208,8 +208,7 @@ disk_cache_type_create(const char *gpu_name,
return cache;
fail:
if (cache)
ralloc_free(cache);
ralloc_free(cache);
ralloc_free(local);
return NULL;

View file

@ -624,8 +624,7 @@ parse_and_validate_cache_item(struct disk_cache *cache, void *cache_item,
return uncompressed_data;
fail:
if (uncompressed_data)
free(uncompressed_data);
free(uncompressed_data);
return NULL;
}
@ -664,10 +663,8 @@ disk_cache_load_item(struct disk_cache *cache, char *filename, size_t *size)
return uncompressed_data;
fail:
if (data)
free(data);
if (filename)
free(filename);
free(data);
free(filename);
if (fd != -1)
close(fd);

View file

@ -936,8 +936,7 @@ _mesa_hash_table_u64_delete_key(struct hash_entry *entry)
struct hash_key_u64 *_key = (struct hash_key_u64 *)entry->key;
if (_key)
FREE(_key);
FREE(_key);
}
void

View file

@ -928,8 +928,7 @@ fail_fatal:
fail:
mesa_db_unlock(db);
if (hash_entry)
ralloc_free(hash_entry);
ralloc_free(hash_entry);
return false;
}

View file

@ -65,8 +65,7 @@ util_idalloc_init(struct util_idalloc *buf, unsigned initial_num_ids)
void
util_idalloc_fini(struct util_idalloc *buf)
{
if (buf->data)
free(buf->data);
free(buf->data);
}
unsigned

View file

@ -79,9 +79,7 @@ __getProgramName()
if (name)
program_name = strdup(name + 1);
}
if (path) {
free(path);
}
free(path);
if (!program_name) {
program_name = strdup(arg+1);
}

View file

@ -207,8 +207,7 @@ util_create_range_remap()
struct range_remap *
util_reset_range_remap(struct range_remap *r_remap)
{
if (r_remap)
ralloc_free(r_remap);
ralloc_free(r_remap);
return util_create_range_remap();
}

View file

@ -1284,9 +1284,7 @@ driDestroyOptionInfo(driOptionCache *info)
if (info->info) {
uint32_t i, size = 1 << info->tableSize;
for (i = 0; i < size; ++i) {
if (info->info[i].name) {
free(info->info[i].name);
}
free(info->info[i].name);
}
free(info->info);
}

View file

@ -167,8 +167,7 @@ vn_cs_encoder_fini(struct vn_cs_encoder *enc)
for (uint32_t i = 0; i < enc->buffer_count; i++)
vn_renderer_shmem_unref(enc->instance->renderer, enc->buffers[i].shmem);
if (enc->buffers)
free(enc->buffers);
free(enc->buffers);
}
/**

View file

@ -580,8 +580,7 @@ vk_common_CreateShadersEXT(VkDevice _device,
}
} else {
for (uint32_t l = 0; l < linked_count; l++) {
if (infos[l].nir != NULL)
ralloc_free(infos[l].nir);
ralloc_free(infos[l].nir);
}
}

View file

@ -878,10 +878,8 @@ cleanup:
png_destroy_write_struct(&png, &info);
if (file)
fclose(file);
if (filename)
free(filename);
if (tmpFilename)
free(tmpFilename);
free(filename);
free(tmpFilename);
return nullptr;
}