mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
Use ftruncate to set shared memory object's size
The posix_fallocate function should only be used with regular files.
This commit is contained in:
parent
b25e230df8
commit
bc5e84225c
1 changed files with 0 additions and 12 deletions
12
util/shm.c
12
util/shm.c
|
@ -42,17 +42,6 @@ int allocate_shm_file(size_t size) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WLR_HAS_POSIX_FALLOCATE) && !defined(__FreeBSD__)
|
|
||||||
int ret;
|
|
||||||
do {
|
|
||||||
ret = posix_fallocate(fd, 0, size);
|
|
||||||
} while (ret == EINTR);
|
|
||||||
if (ret != 0) {
|
|
||||||
close(fd);
|
|
||||||
errno = ret;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int ret;
|
int ret;
|
||||||
do {
|
do {
|
||||||
ret = ftruncate(fd, size);
|
ret = ftruncate(fd, size);
|
||||||
|
@ -61,7 +50,6 @@ int allocate_shm_file(size_t size) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue