diff options
author | marha <marha@users.sourceforge.net> | 2011-10-27 08:37:52 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-10-27 08:37:52 +0200 |
commit | 2a9be4af293f20fa33cc34fbc3b72e2235d91090 (patch) | |
tree | d41608bda1d56be1aa96857dee20e988b53760a3 /mesalib/src/glsl/ralloc.c | |
parent | 9d53da0fbb9ae6df9a38ad40df4f53cd28287235 (diff) | |
parent | d662d461634660f5c0f3998b5eb7d7ed3bd5a25f (diff) | |
download | vcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.tar.gz vcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.tar.bz2 vcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/glsl/ralloc.c')
-rw-r--r-- | mesalib/src/glsl/ralloc.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/mesalib/src/glsl/ralloc.c b/mesalib/src/glsl/ralloc.c index fb48a91c5..f5f3934ac 100644 --- a/mesalib/src/glsl/ralloc.c +++ b/mesalib/src/glsl/ralloc.c @@ -439,7 +439,28 @@ ralloc_asprintf_append(char **str, const char *fmt, ...) bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args) { - size_t existing_length, new_length; + size_t existing_length; + assert(str != NULL); + existing_length = *str ? strlen(*str) : 0; + return ralloc_vasprintf_rewrite_tail(str, existing_length, fmt, args); +} + +bool +ralloc_asprintf_rewrite_tail(char **str, size_t start, const char *fmt, ...) +{ + bool success; + va_list args; + va_start(args, fmt); + success = ralloc_vasprintf_rewrite_tail(str, start, fmt, args); + va_end(args); + return success; +} + +bool +ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt, + va_list args) +{ + size_t new_length; char *ptr; assert(str != NULL); @@ -450,14 +471,13 @@ ralloc_vasprintf_append(char **str, const char *fmt, va_list args) return true; } - existing_length = strlen(*str); new_length = printf_length(fmt, args); - ptr = resize(*str, existing_length + new_length + 1); + ptr = resize(*str, start + new_length + 1); if (unlikely(ptr == NULL)) return false; - vsnprintf(ptr + existing_length, new_length + 1, fmt, args); + vsnprintf(ptr + start, new_length + 1, fmt, args); *str = ptr; return true; } |