mirror of
https://github.com/tezc/sc.git
synced 2025-01-14 06:43:04 +08:00
added mmap double destroy fix for windows
This commit is contained in:
parent
502372b4d6
commit
5799b118b1
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user