[1/2](try 2)msctf: helper functions for generating DWORD cookies
Alexandre Julliard
julliard at winehq.org
Tue Apr 21 09:24:20 CDT 2009
Aric Stewart <aric at codeweavers.com> writes:
> + else if (id_last == array_size)
> + {
> + CookieInternal **new_cookies = NULL;
> + new_cookies = HeapReAlloc(GetProcessHeap(),0,cookies,sizeof(CookieInternal*) * (array_size * 2));
> + if (!new_cookies)
> + {
> + array_size = 0;
> + ERR("Out of memory, Unable to realloc cookies array\n");
> + return 0x0;
> + }
> + cookies = new_cookies;
> + array_size *= 2;
> + }
> +
> + /* try to reuse IDs if possible */
> + for (i = 0; i < id_last; i++)
> + if (cookies[i] == NULL) break;
It would be smarter to reuse the ID before growing the array. Also you
could mark free entries with a 0 id or something like that, and avoid a
level of indirection (and some memory leaks...)
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list