diff options
author | Brian Paul <[email protected]> | 2008-05-17 10:30:21 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-05-17 10:30:21 -0600 |
commit | 9671f7ae476cadb46f9f8f9d0363f24aabaf9f87 (patch) | |
tree | 8fb1c3b27bc41cb5b2a5a144746d5eb5991facbc /src/gallium/auxiliary/tgsi/util/tgsi_parse.c | |
parent | 718a2d8c7a125609a8dca813703047e24de09653 (diff) |
gallium: in drivers, make copy of tokens passed to pipe->create_vs/fs_state()
The caller can then free the token array immediately.
Diffstat (limited to 'src/gallium/auxiliary/tgsi/util/tgsi_parse.c')
-rw-r--r-- | src/gallium/auxiliary/tgsi/util/tgsi_parse.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_parse.c b/src/gallium/auxiliary/tgsi/util/tgsi_parse.c index 5bea7738401..5c0b0bfd61b 100644 --- a/src/gallium/auxiliary/tgsi/util/tgsi_parse.c +++ b/src/gallium/auxiliary/tgsi/util/tgsi_parse.c @@ -330,3 +330,18 @@ tgsi_num_tokens(const struct tgsi_token *tokens) } return 0; } + + +/** + * Make a new copy of a token array. + */ +struct tgsi_token * +tgsi_dup_tokens(const struct tgsi_token *tokens) +{ + unsigned n = tgsi_num_tokens(tokens); + unsigned bytes = n * sizeof(struct tgsi_token); + struct tgsi_token *new_tokens = (struct tgsi_token *) MALLOC(bytes); + if (new_tokens) + memcpy(new_tokens, tokens, bytes); + return new_tokens; +} |