diff options
author | Kenneth Graunke <[email protected]> | 2012-02-09 20:03:36 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2012-02-28 13:07:12 -0800 |
commit | 8292b7419d0405e94a5ea270ba710d20f0eb071f (patch) | |
tree | 06aacf1c3dfc3c592909f54bb57a48d56267c3a8 /src/glsl/ralloc.h | |
parent | 579ccae73d29211c9f5c01ba527e1743ea39c94e (diff) |
ralloc: Make rewrite_tail increase "start" by the new text's length.
Both callers of rewrite_tail immediately compute the new total string
length by adding the (known) length of the existing string plus the
length of the newly appended text. Unfortunately, callers generally
won't know the length of the new text, as it's printf-formatted.
Since ralloc already computes this length, it makes sense to add it in
and save the caller the effort. This simplifies both existing callers,
but more importantly, will allow for cheap-appending in the next commit.
v2: The link_uniforms code needs both the old and new length.
Apply the obvious fix (which sadly makes it less of a cleanup).
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Ian Romanick <[email protected]> [v1]
Acked-by: José Fonseca <[email protected]> [v1]
Diffstat (limited to 'src/glsl/ralloc.h')
-rw-r--r-- | src/glsl/ralloc.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/glsl/ralloc.h b/src/glsl/ralloc.h index 1324f3466bb..86306b1f558 100644 --- a/src/glsl/ralloc.h +++ b/src/glsl/ralloc.h @@ -329,10 +329,11 @@ char *ralloc_vasprintf(const void *ctx, const char *fmt, va_list args); * \param fmt A printf-style formatting string * * \p str will be updated to the new pointer unless allocation fails. + * \p start will be increased by the length of the newly formatted text. * * \return True unless allocation failed. */ -bool ralloc_asprintf_rewrite_tail(char **str, size_t start, +bool ralloc_asprintf_rewrite_tail(char **str, size_t *start, const char *fmt, ...); /** @@ -352,10 +353,11 @@ bool ralloc_asprintf_rewrite_tail(char **str, size_t start, * \param args A va_list containing the data to be formatted * * \p str will be updated to the new pointer unless allocation fails. + * \p start will be increased by the length of the newly formatted text. * * \return True unless allocation failed. */ -bool ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt, +bool ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt, va_list args); /** |