[PATCH v2] mpr: Implement WNetClearConnections().

Pierre Schweitzer pierre at reactos.org
Thu Sep 13 01:43:20 CDT 2018


Le 13/09/2018 à 08:29, Dmitry Timoshkov a écrit :
> Pierre Schweitzer <pierre at reactos.org> wrote:
> 
>> +    size = 0x1000;
>> +    resources = HeapAlloc(GetProcessHeap(), 0, size);
>> +    if (!resources)
>> +    {
>> +        WNetCloseEnum(connected);
>> +        return WN_OUT_OF_MEMORY;
>> +    }
>> +
>> +    do
>> +    {
>> +        size = 0x1000;
>> +        count = -1;
> 
> There is no need to initialize count, you are not verifying it anyway
> after the API call.

I do use it after the API call (see the for loop).
And it's needed to initialize it as it is an IN/OUT parameter (specifies
how many entries you want).

>> +
>> +        memset(resources, 0, size);
>> +        ret = WNetEnumResourceW(connected, &count, resources, &size);
>> +        if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
>> +        {
>> +            iter = resources;
>> +            for (; count; count--)
>> +            {
>> +                WNetCancelConnection2W(iter->lpLocalName, 0, TRUE);
>> +
>> +                iter++;
>> +            }
>> +        }
>> +        else
>> +            break;
>> +    } while (ret != WN_NO_MORE_ENTRIES);
> 
> Since you are using an arbitrary size for NETRESOURCEW array it should be
> possible to avoid dynamic heap allocation by using a fixed size array of
> NETRESOURCEW structures (say 16), or even a single item. That would simplify
> the code.

It's not possible. NETRESOURCEW is a dynamic length structure. Its
strings are append at the end of the structure.

Cheers,
-- 
Pierre Schweitzer <pierre at reactos.org>
System & Network Administrator
Senior Kernel Developer
ReactOS Deutschland e.V.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20180913/ad32b9bd/attachment.sig>


More information about the wine-devel mailing list