mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Don't resize the buffer when there is enough free space.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
a1f938e8e4
commit
c3f8531477
@ -41,20 +41,14 @@ static void vkd3d_string_buffer_clear(struct vkd3d_string_buffer *buffer)
|
||||
|
||||
static bool vkd3d_string_buffer_resize(struct vkd3d_string_buffer *buffer, int rc)
|
||||
{
|
||||
unsigned int new_buffer_size = buffer->buffer_size * 2;
|
||||
char *new_buffer;
|
||||
unsigned int new_buffer_size = rc >= 0 ? buffer->content_size + rc + 1 : max(buffer->buffer_size * 2, 32);
|
||||
|
||||
new_buffer_size = max(new_buffer_size, 32);
|
||||
while (rc > 0 && (unsigned int)rc >= new_buffer_size - buffer->content_size)
|
||||
new_buffer_size *= 2;
|
||||
if (!(new_buffer = vkd3d_realloc(buffer->buffer, new_buffer_size)))
|
||||
if (!vkd3d_array_reserve((void **)&buffer->buffer, &buffer->buffer_size, new_buffer_size, 1))
|
||||
{
|
||||
ERR("Failed to grow buffer.\n");
|
||||
buffer->buffer[buffer->content_size] = '\0';
|
||||
return false;
|
||||
}
|
||||
buffer->buffer = new_buffer;
|
||||
buffer->buffer_size = new_buffer_size;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -912,8 +912,7 @@ void shader_sm4_reset(struct vkd3d_shader_parser *parser);
|
||||
struct vkd3d_string_buffer
|
||||
{
|
||||
char *buffer;
|
||||
unsigned int buffer_size;
|
||||
unsigned int content_size;
|
||||
size_t buffer_size, content_size;
|
||||
};
|
||||
|
||||
struct vkd3d_string_buffer_cache
|
||||
|
Loading…
x
Reference in New Issue
Block a user