[PATCH v2 5/6] setupapi: Implement SetupAddSectionToDiskSpaceList.

Nikolay Sivov nsivov at codeweavers.com
Sun Oct 20 04:31:07 CDT 2019


On 10/19/19 9:55 PM, Vijay Kiran Kamuju wrote:

> +static BOOL get_size_from_inf(HINF layoutinf, WCHAR *filename, LONGLONG *size)
> +{
> +    static const WCHAR SourceDisksFiles[]  = {'S','o','u','r','c','e','D','i','s','k','s','F','i','l','e','s',0};
> +    INFCONTEXT context;
> +    WCHAR buffer[20];
> +
> +    if (!SetupFindFirstLineW(layoutinf, SourceDisksFiles, filename, &context))
> +        return FALSE;
> +
> +    if (!SetupGetStringFieldW(&context, 3, buffer, sizeof(buffer), NULL))
> +        return FALSE;
> +
> +    /* FIXME: is there a atollW ? */
> +    *size = wcstol(buffer, NULL, 10);
There is wcstoll in ucrtbase, and _wcstoi64() otherwise. Also you can 
inline string constants with L"".
> +    return TRUE;
> +}

> +        if (!SetupGetStringFieldW(&context, 1, dest, sizeof(dest) / sizeof(WCHAR), NULL))
> +            goto end;
> +        if (!SetupGetStringFieldW(&context, 2, src, sizeof(src) / sizeof(WCHAR), NULL))
> +            *src = 0;

This should be cleaner if made dynamic, using returned required size.

> +    if (section)
> +    {
> +        len = MultiByteToWideChar(CP_ACP, 0, section, -1, NULL, 0);
> +
> +        sectionW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
> +        if (!sectionW)
> +        {
> +            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
> +            return FALSE;
> +        }
> +
> +        MultiByteToWideChar(CP_ACP, 0, section, -1, sectionW, len);
> +    }
> +
> +    ret = SetupAddSectionToDiskSpaceListW(diskspace, hinf, hlist, sectionW, operation,
> +                                          reserved1, reserved2);
> +    if (sectionW) HeapFree(GetProcessHeap(), 0, sectionW);
> +    return ret;
> +}
Same as for earlier patch, this could be using strdupAtoW().



More information about the wine-devel mailing list