radeon: Add a helper function for freeing members of radeon_shader_binary
authorTom Stellard <thomas.stellard@amd.com>
Wed, 14 Jan 2015 15:01:29 +0000 (10:01 -0500)
committerTom Stellard <thomas.stellard@amd.com>
Tue, 20 Jan 2015 14:55:43 +0000 (09:55 -0500)
src/gallium/drivers/radeon/radeon_elf_util.c
src/gallium/drivers/radeon/radeon_elf_util.h
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_shader.c

index ec39a890950a2815ead99def8f56b74594dba844..8cda57afff6afc1fcf7593d7e004868736f4bdca 100644 (file)
@@ -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);
+}
index 8095e2f19e7c04c336eb6270599dcae1c3b99c7a..ccac56383103eb77bce3936d18d3f6273e9d0baf 100644 (file)
@@ -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 */
index 4b335bbf2fbafa2e6275f23b637cd88ca719837a..f911e1f762030fd79e464d228888d27e0dbbb46b 100644 (file)
@@ -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);
 }
 
index cf28860a35f6cb8360d264ba8fbd485354cf1c67..a891bc651d7bab2afdf3a36b50dc5a867253019a 100644 (file)
@@ -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;
 }