Aric Stewart <aric(a)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(a)winehq.org