summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/glsl/link_uniforms.cpp15
-rw-r--r--src/glsl/linker.h2
-rw-r--r--src/glsl/ralloc.c11
-rw-r--r--src/glsl/ralloc.h6
4 files changed, 18 insertions, 16 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index d51850c216a..613c9b7ae22 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -67,7 +67,7 @@ uniform_field_visitor::process(ir_variable *var)
void
uniform_field_visitor::recursion(const glsl_type *t, char **name,
- unsigned name_length)
+ size_t name_length)
{
/* Records need to have each field processed individually.
*
@@ -78,22 +78,21 @@ uniform_field_visitor::recursion(const glsl_type *t, char **name,
if (t->is_record()) {
for (unsigned i = 0; i < t->length; i++) {
const char *field = t->fields.structure[i].name;
+ size_t new_length = name_length;
/* Append '.field' to the current uniform name. */
- ralloc_asprintf_rewrite_tail(name, name_length, ".%s", field);
+ ralloc_asprintf_rewrite_tail(name, &new_length, ".%s", field);
- recursion(t->fields.structure[i].type, name,
- name_length + 1 + strlen(field));
+ recursion(t->fields.structure[i].type, name, new_length);
}
} else if (t->is_array() && t->fields.array->is_record()) {
for (unsigned i = 0; i < t->length; i++) {
- char subscript[13];
+ size_t new_length = name_length;
/* Append the subscript to the current uniform name */
- const unsigned subscript_length = snprintf(subscript, 13, "[%u]", i);
- ralloc_asprintf_rewrite_tail(name, name_length, "%s", subscript);
+ ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]", i);
- recursion(t->fields.array, name, name_length + subscript_length);
+ recursion(t->fields.array, name, new_length);
}
} else {
this->visit_field(t, *name);
diff --git a/src/glsl/linker.h b/src/glsl/linker.h
index 433c63be246..0b4c001f7e3 100644
--- a/src/glsl/linker.h
+++ b/src/glsl/linker.h
@@ -76,7 +76,7 @@ private:
* \param name_length Length of the current name \b not including the
* terminating \c NUL character.
*/
- void recursion(const glsl_type *t, char **name, unsigned name_length);
+ void recursion(const glsl_type *t, char **name, size_t name_length);
};
#endif /* GLSL_LINKER_H */
diff --git a/src/glsl/ralloc.c b/src/glsl/ralloc.c
index 91e4bab2ebd..2f93dcdeaf7 100644
--- a/src/glsl/ralloc.c
+++ b/src/glsl/ralloc.c
@@ -448,11 +448,11 @@ ralloc_vasprintf_append(char **str, const char *fmt, va_list args)
size_t existing_length;
assert(str != NULL);
existing_length = *str ? strlen(*str) : 0;
- return ralloc_vasprintf_rewrite_tail(str, existing_length, fmt, args);
+ return ralloc_vasprintf_rewrite_tail(str, &existing_length, fmt, args);
}
bool
-ralloc_asprintf_rewrite_tail(char **str, size_t start, const char *fmt, ...)
+ralloc_asprintf_rewrite_tail(char **str, size_t *start, const char *fmt, ...)
{
bool success;
va_list args;
@@ -463,7 +463,7 @@ ralloc_asprintf_rewrite_tail(char **str, size_t start, const char *fmt, ...)
}
bool
-ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt,
+ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt,
va_list args)
{
size_t new_length;
@@ -479,11 +479,12 @@ ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt,
new_length = printf_length(fmt, args);
- ptr = resize(*str, start + new_length + 1);
+ ptr = resize(*str, *start + new_length + 1);
if (unlikely(ptr == NULL))
return false;
- vsnprintf(ptr + start, new_length + 1, fmt, args);
+ vsnprintf(ptr + *start, new_length + 1, fmt, args);
*str = ptr;
+ *start += new_length;
return true;
}
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);
/**