Module: Mesa Branch: main Commit: 57819effc178d90fa7e247ce2c1ae887143bf8b3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=57819effc178d90fa7e247ce2c1ae887143bf8b3
Author: Caio Oliveira <[email protected]> Date: Wed Sep 27 15:49:26 2023 -0700 compiler/types: Remove use of new/delete This is a preparation for moving compiler/types from C++ to C. Reviewed-by: Adam Jackson <[email protected]> Reviewed-by: Emma Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25445> --- src/compiler/glsl_types.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index a4ae831ec8d..b6c60f69216 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -377,14 +377,15 @@ const glsl_type *glsl_type::get_bare_type() const case GLSL_TYPE_STRUCT: case GLSL_TYPE_INTERFACE: { - glsl_struct_field *bare_fields = new glsl_struct_field[this->length]; + struct glsl_struct_field *bare_fields = (struct glsl_struct_field *) + calloc(this->length, sizeof(struct glsl_struct_field)); for (unsigned i = 0; i < this->length; i++) { bare_fields[i].type = this->fields.structure[i].type->get_bare_type(); bare_fields[i].name = this->fields.structure[i].name; } const glsl_type *bare_type = get_struct_instance(bare_fields, this->length, glsl_get_type_name(this)); - delete[] bare_fields; + free(bare_fields); return bare_type; } @@ -2235,7 +2236,8 @@ glsl_type::get_explicit_std140_type(bool row_major) const unsigned stride = align(elem_size, 16); return get_array_instance(elem_type, this->length, stride); } else if (this->is_struct() || this->is_interface()) { - glsl_struct_field *fields = new glsl_struct_field[this->length]; + struct glsl_struct_field *fields = (struct glsl_struct_field *) + calloc(this->length, sizeof(struct glsl_struct_field)); unsigned offset = 0; for (unsigned i = 0; i < length; i++) { fields[i] = this->fields.structure[i]; @@ -2279,7 +2281,7 @@ glsl_type::get_explicit_std140_type(bool row_major) const this->interface_row_major, glsl_get_type_name(this)); - delete[] fields; + free(fields); return type; } else { unreachable("Invalid type for UBO or SSBO"); @@ -2593,7 +2595,8 @@ glsl_type::get_explicit_std430_type(bool row_major) const unsigned stride = this->fields.array->std430_array_stride(row_major); return get_array_instance(elem_type, this->length, stride); } else if (this->is_struct() || this->is_interface()) { - glsl_struct_field *fields = new glsl_struct_field[this->length]; + struct glsl_struct_field *fields = (struct glsl_struct_field *) + calloc(this->length, sizeof(struct glsl_struct_field)); unsigned offset = 0; for (unsigned i = 0; i < length; i++) { fields[i] = this->fields.structure[i]; @@ -2637,7 +2640,7 @@ glsl_type::get_explicit_std430_type(bool row_major) const this->interface_row_major, glsl_get_type_name(this)); - delete[] fields; + free(fields); return type; } else { unreachable("Invalid type for SSBO");
