Mesa (gallium-0.1): tgsi: use REALLOC for growing token pool
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Tue Aug 18 14:26:07 UTC 2009
Module: Mesa
Branch: gallium-0.1
Commit: 46398e77a56f39351ecd5bd74c428279c5801a84
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=46398e77a56f39351ecd5bd74c428279c5801a84
Author: Keith Whitwell <keithw at vmware.com>
Date: Thu Aug 13 14:27:42 2009 +0100
tgsi: use REALLOC for growing token pool
---
src/gallium/auxiliary/tgsi/tgsi_ureg.c | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 00ae0e3..7e1eb0d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -118,7 +118,7 @@ static void tokens_error( struct ureg_tokens *tokens )
static void tokens_expand( struct ureg_tokens *tokens,
unsigned count )
{
- union tgsi_any_token *tmp;
+ unsigned old_size = tokens->size * sizeof(unsigned);
if (tokens->tokens == error_tokens)
goto fail;
@@ -127,18 +127,12 @@ static void tokens_expand( struct ureg_tokens *tokens,
tokens->size = (1 << ++tokens->order);
}
- tmp = MALLOC(tokens->size * sizeof(unsigned));
- if (tmp == NULL) {
- FREE(tokens->tokens);
+ tokens->tokens = REALLOC(tokens->tokens,
+ old_size,
+ tokens->size * sizeof(unsigned));
+ if (tokens->tokens == NULL)
goto fail;
- }
-
- if (tokens->count) {
- memcpy(tmp, tokens->tokens, tokens->count * sizeof tokens->tokens[0] );
- FREE(tokens->tokens);
- }
- tokens->tokens = tmp;
return;
fail:
More information about the mesa-commit
mailing list