diff options
author | Ran Benita <ran234@gmail.com> | 2015-11-19 00:44:27 +0200 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2015-11-19 00:44:27 +0200 |
commit | 2cca028906b6484af25e9e04f3273e854b70cb24 (patch) | |
tree | 3700a4dfba5df2fbcb9ec6c0208ef8ee79d289c5 /src/utils.c | |
parent | c7e2e6d7b4eddac87191f433efd8c34149b96986 (diff) | |
download | xorg-lib-libxkbcommon-2cca028906b6484af25e9e04f3273e854b70cb24.tar.gz |
src/utils: change map_file to not take const string argument
map_file() uses PROT_READ, so const seems fitting; however unmap_file
calls munmap/free, which do not take const, so an UNCONSTIFY is needed.
To avoid the UNCONSTIFY hack, which is likely undefined behavior or some
such, just remove the const.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/utils.c b/src/utils.c index a00b04e..c417106 100644 --- a/src/utils.c +++ b/src/utils.c @@ -32,7 +32,7 @@ #include <sys/types.h> bool -map_file(FILE *file, const char **string_out, size_t *size_out) +map_file(FILE *file, char **string_out, size_t *size_out) { struct stat stat_buf; const int fd = fileno(file); @@ -53,15 +53,15 @@ map_file(FILE *file, const char **string_out, size_t *size_out) } void -unmap_file(const char *str, size_t size) +unmap_file(char *str, size_t size) { - munmap(UNCONSTIFY(str), size); + munmap(str, size); } #else bool -map_file(FILE *file, const char **string_out, size_t *size_out) +map_file(FILE *file, char **string_out, size_t *size_out) { long ret; size_t ret_s; @@ -99,9 +99,9 @@ map_file(FILE *file, const char **string_out, size_t *size_out) } void -unmap_file(const char *str, size_t size) +unmap_file(char *str, size_t size) { - free(UNCONSTIFY(str)); + free(str); } #endif |