From ec6f8c4fe162500645109eb24856051c97bfb2fe Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Mon, 18 Mar 2019 19:45:34 +0100 Subject: Remove the extra argument from cc4group_mmap and cc4group_munmap as its actually not needed --- src/cc4group.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/cc4group.c') diff --git a/src/cc4group.c b/src/cc4group.c index 3947acf..56f4175 100644 --- a/src/cc4group.c +++ b/src/cc4group.c @@ -274,7 +274,7 @@ static void deleteChildren(GroupEntryList* const entries) GroupEntryListDestroy(entries); } -static void* cc4group_mapSizedWriteFd(CC4Group* const this, int fd, size_t size, void** extra) +static void* cc4group_mapSizedWriteFd(CC4Group* const this, int fd, size_t size) { // allocate file size // https://gist.github.com/marcetcheverry/991042 @@ -290,18 +290,17 @@ static void* cc4group_mapSizedWriteFd(CC4Group* const this, int fd, size_t size, return MAP_FAILED; } - return cc4group_mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0, extra); + return cc4group_mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); } typedef struct { void* addr; size_t size; - void* extra; } MunmapData; static void cc4group_unmapTmpMemoryFile(MunmapData* data) { - if(cc4group_munmap(data->addr, data->size, data->extra) == -1) + if(cc4group_munmap(data->addr, data->size) == -1) { fprintf(stderr, "WARNING: munmap: Unmapping tempory file failed: %s\n", strerror(errno)); } @@ -320,8 +319,7 @@ static void* cc4group_createTmpMemoryFile(CC4Group* const this, const size_t siz return NULL; } - void* mmapExtra; - ret = cc4group_mapSizedWriteFd(this, tmpFile, size, &mmapExtra); + ret = cc4group_mapSizedWriteFd(this, tmpFile, size); if(ret == MAP_FAILED) { // error message is set in the method @@ -335,7 +333,7 @@ static void* cc4group_createTmpMemoryFile(CC4Group* const this, const size_t siz { SET_ERRNO_ERROR("malloc: allocating memory for cleanup data"); - if(cc4group_munmap(ret, size, mmapExtra) == -1) + if(cc4group_munmap(ret, size) == -1) { SET_ERRNO_ERROR("malloc: allocating memory for cleanup data; additionally munmap: unmapping the mapped file failed"); } @@ -343,7 +341,7 @@ static void* cc4group_createTmpMemoryFile(CC4Group* const this, const size_t siz } else { - *unmapData = (MunmapData){ret, size, mmapExtra}; + *unmapData = (MunmapData){ret, size}; *cleanupJob = (CC4Group_CleanupJob){(CC4Group_CleanupFunc)cc4group_unmapTmpMemoryFile, unmapData}; } } @@ -835,7 +833,6 @@ static bool cc4group_setSubRoot(CC4Group* const this, const char* const subPath) static bool cc4group_uncompressGroupFromFile(CC4Group* const this, const char* const path) { uint8_t* mappedFile = MAP_FAILED; - void* mapExtra; bool success = false; char* slash = NULL; @@ -894,7 +891,7 @@ static bool cc4group_uncompressGroupFromFile(CC4Group* const this, const char* c } off_t size = st.st_size; - mappedFile = cc4group_mmap(NULL, size, PROT_READ, MAP_PRIVATE, file, 0, &mapExtra); + mappedFile = cc4group_mmap(NULL, size, PROT_READ, MAP_PRIVATE, file, 0); if(close(file) == -1) { @@ -914,7 +911,7 @@ static bool cc4group_uncompressGroupFromFile(CC4Group* const this, const char* c ret: if(mappedFile != MAP_FAILED) { - if(cc4group_munmap(mappedFile, size, mapExtra) == -1) + if(cc4group_munmap(mappedFile, size) == -1) { fprintf(stderr, "WARNING: munmap: Unmapping the group file failed: %s\n", strerror(errno)); } -- cgit v1.2.3-54-g00ecf