tgsi: use REALLOC for growing token pool

This commit is contained in:
Keith Whitwell 2009-08-13 14:27:42 +01:00
parent 120e76866b
commit 749e52049d
1 changed files with 5 additions and 11 deletions

View File

@ -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: