Fix memory and style issues

This commit is contained in:
Piotr Krygier
2026-03-20 11:40:09 +01:00
parent c531f5fb55
commit 4c706982f1
2 changed files with 13 additions and 16 deletions
+13 -14
View File
@@ -77,29 +77,26 @@ rse_err_t mesh_create_from_file(struct graphics_context_t* context, const char*
STATUS_CHECK(file_load_gltf(file_name, &data));
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "Attribute name: %s", data->meshes->primitives[0].attributes[3].name);
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "Accessor: %ld", data->meshes->primitives[0].attributes[3].data->count);
for (mesh_index = 0U; mesh_index < data->meshes_count; ++mesh_index) {
mesh = &data->meshes[mesh_index];
for (primitive_index = 0U; primitive_index < mesh->primitives_count; ++primitive_index) {
primitive = &mesh->primitives[primitive_index];
if (primitive->indices == NULL) {
SDL_LogCritical(SDL_LOG_CATEGORY_GPU,
"No indices for mesh found. Currently only indexed drawing is supported");
return RSE_ERROR_INVALID_PARAM;
} else {
rse_malloc(indices_data_offset, sizeof(size_t));
*indices_data_offset = primitive->indices->buffer_view->offset;
indices_count = primitive->indices->count;
rse_malloc(indices, (sizeof(uint16_t) * indices_count));
}
for (attribute_index = 0; attribute_index < primitive->attributes_count; ++attribute_index) {
attribute = &primitive->attributes[attribute_index];
if (primitive->indices == NULL) {
SDL_LogCritical(SDL_LOG_CATEGORY_GPU,
"No indices for mesh found. Currently only indexed drawing is supported");
return RSE_ERROR_INVALID_PARAM;
} else {
rse_malloc(indices_data_offset, sizeof(size_t));
*indices_data_offset = primitive->indices->buffer_view->offset;
indices_count = primitive->indices->count;
rse_malloc(indices, (sizeof(uint16_t) * indices_count));
}
tmp_offset = attribute->data->buffer_view->offset;
switch (attribute->type) {
@@ -169,7 +166,9 @@ exit:
rse_free(position_data_offset);
rse_free(color_data_offset);
rse_free(texture_coord_data_offset);
rse_free(indices_data_offset);
rse_free(vertices);
rse_free(indices);
cgltf_free(data);
return status;
-2
View File
@@ -1,7 +1,5 @@
#include "red_scarf_engine.h"
#include "utilities/commons.h"
#include "utilities/errors_common.h"
#include "graphics/src/mesh_controller.h"
int main(int argc, char** argv)
{