Browse Source

replaced last of the remaining explicit calls to std::calloc/std::free

master
cinnaboot 8 years ago
parent
commit
e3ad1b7ba6
  1. 1
      TODO.md
  2. 4
      src/render_group.cpp
  3. 1
      src/renderer.cpp
  4. 3
      src/util.cpp

1
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:

4
src/render_group.cpp

@ -1,7 +1,6 @@
#include <sstream> // TODO: remove this and make something in util.h
#include <cassert>
#include <cstdlib> // calloc
#include <glm/glm.hpp>
#include <glm/geometric.hpp>
@ -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];

1
src/renderer.cpp

@ -1,7 +1,6 @@
#include <vector>
#include <cmath> // trig functions
#include <cstdlib> // calloc
#if defined (_WIN32)
#include <SDL.h>

3
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);

Loading…
Cancel
Save