[PATCH 2/5] kernel32: Reimplement GetActiveProcessorGroupCount on top of GetLogicalProcessorInformationEx

Dmitry Timoshkov dmitry at baikal.ru
Mon May 24 01:58:35 CDT 2021


Alex Henrie <alexhenrie24 at gmail.com> wrote:

>  WORD WINAPI GetActiveProcessorGroupCount(void)
>  {
> -    FIXME("semi-stub, always returning 1\n");
> -    return 1;
> +    WORD groups;
> +    DWORD size = 0;
> +    SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info;
> +
> +    TRACE("()\n");
> +
> +    if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0;
> +    if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0;
> +    if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size)) return 0;

Memory is leaked here.

> +
> +    groups = info->Group.ActiveGroupCount;
> +
> +    HeapFree(GetProcessHeap(), 0, info);
> +    return groups;
>  }

After looking at the ntdll implementation it seems, that it should be
possible to avoid memory allocation and use buffer of a fixed size.

-- 
Dmitry.



More information about the wine-devel mailing list