summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-08-13 14:27:42 +0100
committerKeith Whitwell <[email protected]>2009-08-13 14:27:42 +0100
commit749e52049dee6717023309f6446efb2c89ed720c (patch)
tree4819946ceb8d50502bdee5373f3f5fb6034b51c7 /src/gallium/auxiliary/tgsi
parent120e76866b4b0d136ae4ed377c6ff96454e39b95 (diff)
tgsi: use REALLOC for growing token pool
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c16
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 00ae0e3f06f..7e1eb0dc0a0 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: