added mmap double destroy fix for windows

This commit is contained in:
tezc 2021-04-13 23:10:42 +03:00
parent 502372b4d6
commit 5799b118b1

View File

@ -165,16 +165,27 @@ int sc_mmap_munlock(struct sc_mmap *m, size_t offset, size_t len)
int sc_mmap_term(struct sc_mmap *m)
{
BOOL b;
int rc = 0;
if (m->fd == -1) {
return 0;
}
_close(m->fd);
b = UnmapViewOfFile(m->ptr);
if (b == 0) {
sc_mmap_errstr(m);
return -1;
rc = -1;
}
return 0;
*m = (struct sc_mmap){
.ptr = NULL,
.fd = -1,
.len = 0,
};
return rc;
}
#else
@ -272,7 +283,7 @@ int sc_mmap_term(struct sc_mmap *m)
strncpy(m->err, strerror(errno), sizeof(m->err) - 1);
}
*m = (struct sc_mmap) {
*m = (struct sc_mmap){
.ptr = NULL,
.fd = -1,
.len = 0,