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)
|
int sc_mmap_term(struct sc_mmap *m)
|
||||||
{
|
{
|
||||||
BOOL b;
|
BOOL b;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if (m->fd == -1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
_close(m->fd);
|
_close(m->fd);
|
||||||
|
|
||||||
b = UnmapViewOfFile(m->ptr);
|
b = UnmapViewOfFile(m->ptr);
|
||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
sc_mmap_errstr(m);
|
sc_mmap_errstr(m);
|
||||||
return -1;
|
rc = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
*m = (struct sc_mmap){
|
||||||
|
.ptr = NULL,
|
||||||
|
.fd = -1,
|
||||||
|
.len = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -272,7 +283,7 @@ int sc_mmap_term(struct sc_mmap *m)
|
|||||||
strncpy(m->err, strerror(errno), sizeof(m->err) - 1);
|
strncpy(m->err, strerror(errno), sizeof(m->err) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
*m = (struct sc_mmap) {
|
*m = (struct sc_mmap){
|
||||||
.ptr = NULL,
|
.ptr = NULL,
|
||||||
.fd = -1,
|
.fd = -1,
|
||||||
.len = 0,
|
.len = 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user