misc: fix return value of memory functions (#3818)
Specifically uv_get_free_memory and uv_get_total_memory.
This commit is contained in:
parent
3706c4f855
commit
6f69654294
@ -107,7 +107,7 @@ uint64_t uv_get_free_memory(void) {
|
||||
|
||||
if (host_statistics(mach_host_self(), HOST_VM_INFO,
|
||||
(host_info_t)&info, &count) != KERN_SUCCESS) {
|
||||
return UV_EINVAL; /* FIXME(bnoordhuis) Translate error. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (uint64_t) info.free_count * sysconf(_SC_PAGESIZE);
|
||||
@ -120,7 +120,7 @@ uint64_t uv_get_total_memory(void) {
|
||||
size_t size = sizeof(info);
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
return 0;
|
||||
|
||||
return (uint64_t) info;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ uint64_t uv_get_free_memory(void) {
|
||||
size_t size = sizeof(freecount);
|
||||
|
||||
if (sysctlbyname("vm.stats.vm.v_free_count", &freecount, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
return 0;
|
||||
|
||||
return (uint64_t) freecount * sysconf(_SC_PAGESIZE);
|
||||
|
||||
@ -105,7 +105,7 @@ uint64_t uv_get_total_memory(void) {
|
||||
size_t size = sizeof(info);
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
return 0;
|
||||
|
||||
return (uint64_t) info;
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ uint64_t uv_get_free_memory(void) {
|
||||
int which[] = {CTL_VM, VM_UVMEXP};
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
return 0;
|
||||
|
||||
return (uint64_t) info.free * sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
@ -120,7 +120,7 @@ uint64_t uv_get_total_memory(void) {
|
||||
size_t size = sizeof(info);
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
return 0;
|
||||
|
||||
return (uint64_t) info;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ uint64_t uv_get_free_memory(void) {
|
||||
int which[] = {CTL_VM, VM_UVMEXP};
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
return 0;
|
||||
|
||||
return (uint64_t) info.free * sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
@ -128,7 +128,7 @@ uint64_t uv_get_total_memory(void) {
|
||||
size_t size = sizeof(info);
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
return 0;
|
||||
|
||||
return (uint64_t) info;
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ uint64_t uv_get_free_memory(void) {
|
||||
memory_status.dwLength = sizeof(memory_status);
|
||||
|
||||
if (!GlobalMemoryStatusEx(&memory_status)) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (uint64_t)memory_status.ullAvailPhys;
|
||||
@ -350,7 +350,7 @@ uint64_t uv_get_total_memory(void) {
|
||||
memory_status.dwLength = sizeof(memory_status);
|
||||
|
||||
if (!GlobalMemoryStatusEx(&memory_status)) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (uint64_t)memory_status.ullTotalPhys;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user