diff --git a/TODO.md b/TODO.md index d1fd732..5f15cda 100644 --- a/TODO.md +++ b/TODO.md @@ -37,7 +37,6 @@ - actually don't need to save the vertex/normal buffers after passing to opengl - use a storage pool for assimp meshes allowing reuse across entities - also cache textures from loaded meshes for re-use -- replace remaining calls to malloc/free with safe(r) function in util.h - remove v2i/v3f... etc from util.h and either use glm everywhere, or write a smaller linear math.h ## LATER TODO: diff --git a/src/render_group.cpp b/src/render_group.cpp index 58b5024..b2c0b38 100644 --- a/src/render_group.cpp +++ b/src/render_group.cpp @@ -1,7 +1,6 @@ #include // TODO: remove this and make something in util.h #include -#include // calloc #include #include @@ -127,14 +126,13 @@ rgInitEntity(Entity* e) rg->draw_mode = GL_TRIANGLES; rg->use_normals = e->mesh_group.use_normals; uint num_meshes = rg->num_objects = e->mesh_group.num_meshes; + rg->render_objects = UTIL_ALLOC(num_meshes, render_object*); // apply translation/rotation/scaling e->world_transform = glm::mat4(1.0); e->world_transform = glm::translate(e->world_transform, e->translation); e->world_transform = glm::scale(e->world_transform, e->scale); - rg->render_objects = (render_object**) std::calloc(num_meshes, sizeof(render_object*)); - for (uint i = 0; i < num_meshes; i++) { meMeshInfo* mesh = e->mesh_group.meshes[i]; diff --git a/src/renderer.cpp b/src/renderer.cpp index d166bb2..eac32c6 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -1,7 +1,6 @@ #include #include // trig functions -#include // calloc #if defined (_WIN32) #include diff --git a/src/util.cpp b/src/util.cpp index d0dd037..c29a02a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -89,7 +89,6 @@ utilLogAlloc(uint item_count, uint type_size, const char* file_name, const int l return mem; } -// TODO: search/replace other calls to std::free with this void utilSafeFree(const void* mem) { if (mem != nullptr) { @@ -116,7 +115,7 @@ utilDumpTextFile(const char* filename) assert(length < MAX_FILESIZE); // TODO: check error codes for fseek and ftell - char* buf = (char *) std::calloc(length, sizeof(char)); + char* buf = UTIL_ALLOC(length, char); assert(buf); std::fread(buf, sizeof(char), length, fp);