[Mesa-dev] [PATCH 1/5] radeon: Add a helper function for freeing members of radeon_shader_binary
Tom Stellard
thomas.stellard at amd.com
Thu Jan 15 16:48:05 PST 2015
---
src/gallium/drivers/radeon/radeon_elf_util.c | 6 ++++++
src/gallium/drivers/radeon/radeon_elf_util.h | 5 +++++
src/gallium/drivers/radeonsi/si_compute.c | 4 +---
src/gallium/drivers/radeonsi/si_shader.c | 4 +---
4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/radeon/radeon_elf_util.c b/src/gallium/drivers/radeon/radeon_elf_util.c
index ec39a89..8cda57a 100644
--- a/src/gallium/drivers/radeon/radeon_elf_util.c
+++ b/src/gallium/drivers/radeon/radeon_elf_util.c
@@ -161,3 +161,9 @@ const unsigned char *radeon_shader_binary_config_start(
}
return binary->config;
}
+
+void radeon_shader_binary_free_members(struct radeon_shader_binary *binary) {
+ FREE(binary->code);
+ FREE(binary->config);
+ FREE(binary->rodata);
+}
diff --git a/src/gallium/drivers/radeon/radeon_elf_util.h b/src/gallium/drivers/radeon/radeon_elf_util.h
index 8095e2f..ccac563 100644
--- a/src/gallium/drivers/radeon/radeon_elf_util.h
+++ b/src/gallium/drivers/radeon/radeon_elf_util.h
@@ -46,4 +46,9 @@ const unsigned char *radeon_shader_binary_config_start(
const struct radeon_shader_binary *binary,
uint64_t symbol_offset);
+/**
+ * Free all memory allocated for members of \p binary. This function does
+ * not free \p binary.
+ */
+void radeon_shader_binary_free_members(struct radeon_shader_binary *binary);
#endif /* RADEON_ELF_UTIL_H */
diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c
index 4b335bb..f911e1f 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -439,9 +439,7 @@ static void si_delete_compute_state(struct pipe_context *ctx, void* state){
pipe_resource_reference(
(struct pipe_resource **)&program->input_buffer, NULL);
- FREE(program->binary.code);
- FREE(program->binary.config);
- FREE(program->binary.rodata);
+ radeon_shader_binary_free_members(&program->binary);
FREE(program);
}
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index cf28860..a891bc6 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2621,9 +2621,7 @@ int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader,
return r;
}
r = si_shader_binary_read(sscreen, shader, &binary);
- FREE(binary.code);
- FREE(binary.config);
- FREE(binary.rodata);
+ radeon_shader_binary_free_members(&binary);
return r;
}
--
1.8.5.5
More information about the mesa-dev
mailing list