Skip to content

Commit 2d89b32

Browse files
authored
Clean up (#372)
There are redundant codes for cleaning up the memory, thus refine them. Also, prof_out_file should be freed in commit 0b8a712 but it did not, so it does in this commit.
1 parent ed5d95f commit 2d89b32

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ int main(int argc, char **args)
206206
riscv_t *rv = rv_create(&attr);
207207
if (!rv) {
208208
fprintf(stderr, "Unable to create riscv emulator\n");
209-
free(attr.data.user);
210-
return 1;
209+
attr.exit_code = 1;
210+
goto end;
211211
}
212212

213213
rv_run(rv);
@@ -224,6 +224,9 @@ int main(int argc, char **args)
224224
rv_delete(rv);
225225

226226
printf("inferior exit code %d\n", attr.exit_code);
227+
228+
end:
227229
free(attr.data.user);
228-
return 0;
230+
free(prof_out_file);
231+
return attr.exit_code;
229232
}

0 commit comments

Comments
 (0)