return -1;
}
-/* Use the Win32 API to get the number of processors */
+/* Use the Win32 API to get the number of processors. */
unsigned
win32_get_number_of_processors(void)
{
return sysinfo.dwNumberOfProcessors;
}
+/* Use the Win32 API to get the amount of available memory. */
+u64
+win32_get_avail_memory(void)
+{
+ MEMORYSTATUSEX status = {
+ .dwLength = sizeof(status),
+ };
+ GlobalMemoryStatusEx(&status);
+ return status.ullTotalPhys;
+}
+
/* Replacement for POSIX-2008 realpath(). Warning: partial functionality only
* (resolved_path must be NULL). Also I highly doubt that GetFullPathName
* really does the right thing under all circumstances. */
ret = GetFullPathNameW(path, ret, resolved_path, NULL);
if (!ret) {
err = GetLastError();
- free(resolved_path);
+ FREE(resolved_path);
resolved_path = NULL;
goto fail_win32;
}
return do_pread_or_pwrite(fd, (void*)buf, count, offset, true);
}
+#if 0
/* Dumb Windows implementation of writev(). It writes the vectors one at a
* time. */
ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
}
return total_bytes_written;
}
+#endif
int
win32_get_file_and_vol_ids(const wchar_t *path, u64 *ino_ret, u64 *dev_ret)
{
size_t i;
for (i = 0; i < pglob->gl_pathc; i++)
- free(pglob->gl_pathv[i]);
- free(pglob->gl_pathv);
+ FREE(pglob->gl_pathv[i]);
+ FREE(pglob->gl_pathv);
}
#endif /* __WIN32__ */