diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-04-14 15:23:52 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-04-14 15:46:48 +0200 |
commit | 2154de1cf36c0ac741f258f72de6895e8782ec79 (patch) | |
tree | 059eb2c27be8918d7edf26382912549ec4962e32 /common/imd.c | |
parent | cc9c2d3dd0ee72730dcdb6975da520b13d1ed75c (diff) | |
download | barebox-2154de1cf36c0ac741f258f72de6895e8782ec79.tar.gz barebox-2154de1cf36c0ac741f258f72de6895e8782ec79.tar.xz |
bareboximd: Use mmap when possibly
It's hard to believe but there are systems out there that are so sparse
with memory that they can't afford 1MiB of RAM to read a file into.
Use mmap when possible and fall back to reading into an allocated buffer
otherwise.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/imd.c')
-rw-r--r-- | common/imd.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/common/imd.c b/common/imd.c index aff3b00b6b..e1d5733c6b 100644 --- a/common/imd.c +++ b/common/imd.c @@ -17,6 +17,10 @@ int imd_command_setenv(const char *variable_name, const char *value) return -ENOSYS; } #endif +static inline void read_file_2_free(void *buf) +{ + free(buf); +} #endif /* @@ -542,6 +546,6 @@ int imd_command(int argc, char *argv[]) ret = 0; out: - free(buf); + read_file_2_free(buf); return ret; } |