win32_mmap writes to *user, which is io->fd.sys. However, default_io is const so writing to it causes a segmentation fault. There's no need to keep the file mapping HANDLE around, so this patch just stores it locally then closes it right away.
Also, returning the pointer plus the offset appears to be the wrong behavior. I was getting segfaults until I changed it to return just the pointer, like POSIX mmap.
With these changes applied, zziplib can use mmap when (cross-)compiled with mingw. I believe they should work fine for MSVC but I have not tried them.
Log in to post a comment.