Przeglądaj źródła

Remove NULL checks before free().

master
Ben Kurtovic 9 lat temu
rodzic
commit
1383d57f29
3 zmienionych plików z 7 dodań i 14 usunięć
  1. +1
    -2
      src/assembler/state.c
  2. +4
    -8
      src/config.c
  3. +2
    -4
      src/rom.c

+ 1
- 2
src/assembler/state.c Wyświetl plik

@@ -89,8 +89,7 @@ void asm_instructions_free(ASMInstruction *inst)
while (inst) { while (inst) {
ASMInstruction *temp = inst->next; ASMInstruction *temp = inst->next;
free(inst->bytes); free(inst->bytes);
if (inst->symbol)
free(inst->symbol);
free(inst->symbol);
free(inst); free(inst);
inst = temp; inst = temp;
} }


+ 4
- 8
src/config.c Wyświetl plik

@@ -136,8 +136,7 @@ static char* get_rom_path_from_user()
if (paths[i] != path) if (paths[i] != path)
free(paths[i]); free(paths[i]);
} }
if (paths)
free(paths);
free(paths);
return path; return path;
} }


@@ -351,12 +350,9 @@ int config_create(Config** config_ptr, int argc, char* argv[])
*/ */
void config_destroy(Config *config) 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); free(config);
} }




+ 2
- 4
src/rom.c Wyświetl plik

@@ -261,10 +261,8 @@ const char* rom_open(ROM **rom_ptr, const char *path)
*/ */
void rom_close(ROM *rom) 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); free(rom);
} }




Ładowanie…
Anuluj
Zapisz