Closed zoanana990 closed 1 year ago
Check https://github.com/jserv/semu/blob/master/CONTRIBUTING.md carefully and ensure the consistent style.
Any update?
yes, coding style was changed, but i don't know why i need to use atexit(3) to perform the munmap operation, is this for error handling? like the following code:
void cleanup(*addr, size_t len)
{
munmap(...)
}
static void read_file_into_ram(char **ram_loc, const char *name)
{
...
if (*ram_loc == MAP_FAILED) {
fprintf(stderr, "mmap failed\n");
atexit(cleanup);
}
}
yes, coding style was changed, but i don't know why i need to use atexit(3) to perform the munmap operation, is this for error handling? like the following code:
No, atexit
is invoked right after mmap
succeeds. It is used for normal execution path rather than the abnormal one. i.e., exception handling.
Superseded by commit 944a51d612aef623b51ebcdd4956336bae61e0a6
Thank @zoanana990 for contributing.
Replace
fread
withmmap
methodPerformance comparison Load Linux image: