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.
*
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);
* \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 */
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;
}
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;
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;
}
* \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, ...);
/**
* \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);
/**