#include "compiler/glsl/glsl_parser_extras.h"
#include "glsl_types.h"
#include "util/hash_table.h"
+#include "util/u_string.h"
mtx_t glsl_type::hash_mutex = _MTX_INITIALIZER_NP;
assert(name != NULL);
this->name = ralloc_strdup(this->mem_ctx, name);
- this->fields.structure = ralloc_array(this->mem_ctx,
- glsl_struct_field, length);
+ /* Zero-fill to prevent spurious Valgrind errors when serializing NIR
+ * due to uninitialized unused bits in bit fields. */
+ this->fields.structure = rzalloc_array(this->mem_ctx,
+ glsl_struct_field, length);
for (i = 0; i < length; i++) {
this->fields.structure[i] = fields[i];
char *const n = (char *) ralloc_size(this->mem_ctx, name_length);
if (length == 0)
- snprintf(n, name_length, "%s[]", array->name);
+ util_snprintf(n, name_length, "%s[]", array->name);
else {
/* insert outermost dimensions in the correct spot
* otherwise the dimension order will be backwards
const char *pos = strchr(array->name, '[');
if (pos) {
int idx = pos - array->name;
- snprintf(n, idx+1, "%s", array->name);
- snprintf(n + idx, name_length - idx, "[%u]%s",
- length, array->name + idx);
+ util_snprintf(n, idx+1, "%s", array->name);
+ util_snprintf(n + idx, name_length - idx, "[%u]%s",
+ length, array->name + idx);
} else {
- snprintf(n, name_length, "%s[%u]", array->name, length);
+ util_snprintf(n, name_length, "%s[%u]", array->name, length);
}
}
* named 'foo'.
*/
char key[128];
- snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size);
+ util_snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size);
mtx_lock(&glsl_type::hash_mutex);