From 1383d57f29048d583b05291a6860babeac9ee5e0 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 27 Apr 2015 13:51:24 -0500 Subject: [PATCH] Remove NULL checks before free(). --- src/assembler/state.c | 3 +-- src/config.c | 12 ++++-------- src/rom.c | 6 ++---- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/assembler/state.c b/src/assembler/state.c index a6fe1a4..ef39172 100644 --- a/src/assembler/state.c +++ b/src/assembler/state.c @@ -89,8 +89,7 @@ void asm_instructions_free(ASMInstruction *inst) while (inst) { ASMInstruction *temp = inst->next; free(inst->bytes); - if (inst->symbol) - free(inst->symbol); + free(inst->symbol); free(inst); inst = temp; } diff --git a/src/config.c b/src/config.c index 893f9f5..0aeae5b 100644 --- a/src/config.c +++ b/src/config.c @@ -136,8 +136,7 @@ static char* get_rom_path_from_user() if (paths[i] != path) free(paths[i]); } - if (paths) - free(paths); + free(paths); return path; } @@ -351,12 +350,9 @@ int config_create(Config** config_ptr, int argc, char* argv[]) */ void config_destroy(Config *config) { - if (config->rom_path) - free(config->rom_path); - if (config->src_path) - free(config->src_path); - if (config->dst_path) - free(config->dst_path); + free(config->rom_path); + free(config->src_path); + free(config->dst_path); free(config); } diff --git a/src/rom.c b/src/rom.c index 4a65c88..2e9589c 100644 --- a/src/rom.c +++ b/src/rom.c @@ -261,10 +261,8 @@ const char* rom_open(ROM **rom_ptr, const char *path) */ void rom_close(ROM *rom) { - if (rom->name) - free(rom->name); - if (rom->data) - free(rom->data); + free(rom->name); + free(rom->data); free(rom); }