static wchar_t *zbx_wcsdup2(const char *filename, int line, wchar_t *old, const wchar_t *str)
for (int retry = 10; 0 < retry && NULL == ptr; ptr = wcsdup(str), retry--)
zabbix_log(LOG_LEVEL_CRIT, "[file:%s,line:%d] zbx_wcsdup: out of memory. Requested " ZBX_FS_SIZE_T " bytes.",
filename, line, (zbx_fs_size_t)((wcslen(str) + 1) * sizeof(wchar_t)));
static int wmpoint_compare_func(const void *d1, const void *d2)
const zbx_wmpoint_t *m1 = *(const zbx_wmpoint_t **)d1;
const zbx_wmpoint_t *m2 = *(const zbx_wmpoint_t **)d2;
return strcmp(m1->fsname, m2->fsname);
static int get_fs_size_stat(const char *fs, zbx_uint64_t *total, zbx_uint64_t *not_used,
zbx_uint64_t *used, double *pfree, double *pused, char **error)
ULARGE_INTEGER freeBytes, totalBytes;
wpath = zbx_utf8_to_unicode(fs);
if (0 == GetDiskFreeSpaceEx(wpath, &freeBytes, &totalBytes, NULL))
*error = zbx_dsprintf(NULL, "Cannot obtain filesystem information: %s",
zbx_strerror_from_system(GetLastError()));
zabbix_log(LOG_LEVEL_DEBUG,"%s failed with error: %s",__func__, *error);
*total = totalBytes.QuadPart;
*not_used = freeBytes.QuadPart;
if (0 != totalBytes.QuadPart)
*used = totalBytes.QuadPart - freeBytes.QuadPart;
*pfree = (double)(__int64)freeBytes.QuadPart * 100. / (double)(__int64)totalBytes.QuadPart;
*pused = (double)((__int64)totalBytes.QuadPart - (__int64)freeBytes.QuadPart) * 100. /
(double)(__int64)totalBytes.QuadPart;