mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-01-08 14:28:23 -05:00
libobs/util: Update os_get_free_size()
`os_get_free_size()` was simply returning 0. For Linux, implement the free size calculation based on the `sysinfo()` system call.
This commit is contained in:
committed by
Ryan Foster
parent
abb8cdf0da
commit
935613816f
@@ -1032,11 +1032,6 @@ uint64_t os_get_proc_virtual_size(void)
|
||||
return (uint64_t)kinfo.ki_size;
|
||||
}
|
||||
#else
|
||||
uint64_t os_get_sys_free_size(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
unsigned long virtual_size;
|
||||
unsigned long resident_size;
|
||||
@@ -1116,6 +1111,20 @@ uint64_t os_get_sys_total_size(void)
|
||||
|
||||
return total_memory;
|
||||
}
|
||||
|
||||
uint64_t os_get_sys_free_size(void)
|
||||
{
|
||||
uint64_t free_memory = 0;
|
||||
#ifndef __OpenBSD__
|
||||
struct sysinfo info;
|
||||
if (sysinfo(&info) < 0)
|
||||
return 0;
|
||||
|
||||
free_memory = ((uint64_t)info.freeram + (uint64_t)info.bufferram) * info.mem_unit;
|
||||
#endif
|
||||
|
||||
return free_memory;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
|
||||
Reference in New Issue
Block a user