Is there some technical reason behind using a dynamic allocation for the cgltf_data output structure? Since it's a static size, I think it would be more convenient and practical to do something like this:
#define CGLTF_IMPLEMENTATION
#include "cgltf.h"
void* buf; /* Pointer to glb or gltf file data */
size_t size; /* Size of the file data */
cgltf_options options = {0};
cgltf_data data = {0};
cgltf_result result = cgltf_parse(&options, buf, size, &data);
if (result == cgltf_result_success) {
/* [Do stuff with data] */
}
You’d still need cgltf_free; it’s easier to forget in code like above. With that it doesn’t seem like ergonomics is any better, and cgltf allocates enough that one extra allocation won’t matter for performance.
Is there some technical reason behind using a dynamic allocation for the
cgltf_data
output structure? Since it's a static size, I think it would be more convenient and practical to do something like this: