Rémi Bernon (@rbernon) commented about dlls/wintypes/buffer.c:
- TRACE( "iface %p, capacity %u, value %p\n", iface, capacity, value );
- *value = NULL;
- if (capacity > get_max_capacity() || !(impl = calloc( 1, sizeof( *impl ) ))) return E_OUTOFMEMORY;
- impl->IBuffer_iface.lpVtbl = &buffer_vtbl;
- impl->ref = 1;
- impl->capacity = capacity;
- impl->length = 0;
- if (!(impl->data = malloc( capacity )))
- {
free( impl );
return E_OUTOFMEMORY;
- }
If buffer cannot grow, we should use a single allocation instead and let malloc decide whether it succeeds without having a specific limit. Use a variable sized struct buffer, like hstring_vector in dlls/windows.globalization/main.c (please include a similar C_ASSERT too).