On Thu, Nov 01, 2018 at 09:57:37AM +0000, Huw Davies wrote:
On Wed, Oct 31, 2018 at 01:24:28PM +0200, Gabriel Ivăncescu wrote:
- UINT i, cur = 0, array_size = 1024;
- LPOLESTR *strs = NULL, *tmp;
- ULONG n;
- do
- {
if ((tmp = heap_realloc(strs, array_size * sizeof(*strs))) == NULL)
goto fail;
strs = tmp;
do
IEnumString_Next(ac->enumstr, array_size - cur, &strs[cur], &n);
while (n != 0 && (cur += n) < array_size);
array_size *= 2;
- } while (n != 0);
Hopefully you agree that this looks much nicer than the previous versions. There's a slight issue though in that you should check that the return value from IEnumString_Next() == S_OK. You could simply then set n = 0 if that condition isn't met, to break out of the loops.
Sorry, actually test using FAILED(). IEnumString_Next() is supposed to return S_FALSE if the number read < number asked for.
Huw.