diff --git a/graphics/tinygl/memory.cpp b/graphics/tinygl/memory.cpp index d756e39103c..280d90070da 100644 --- a/graphics/tinygl/memory.cpp +++ b/graphics/tinygl/memory.cpp @@ -45,4 +45,8 @@ void *gl_zalloc(int size) { return calloc(1, size); } +void *gl_realloc(void *p, int size) { + return realloc(p, size); +} + } // end of namespace TinyGL diff --git a/graphics/tinygl/vertex.cpp b/graphics/tinygl/vertex.cpp index db70b1bbd85..fa99885e6ea 100644 --- a/graphics/tinygl/vertex.cpp +++ b/graphics/tinygl/vertex.cpp @@ -209,12 +209,10 @@ void GLContext::glopVertex(GLParam *p) { if (n >= vertex_max) { GLVertex *newarray; vertex_max <<= 1; // just double size - newarray = (GLVertex *)gl_malloc(sizeof(GLVertex) * vertex_max); + newarray = (GLVertex *)gl_realloc(vertex, sizeof(GLVertex) * vertex_max); if (!newarray) { error("unable to allocate GLVertex array."); } - memcpy(newarray, vertex, n * sizeof(GLVertex)); - gl_free(vertex); vertex = newarray; } // new vertex entry diff --git a/graphics/tinygl/zbuffer.h b/graphics/tinygl/zbuffer.h index ea325b9a803..797062d24b0 100644 --- a/graphics/tinygl/zbuffer.h +++ b/graphics/tinygl/zbuffer.h @@ -742,6 +742,7 @@ private: void gl_free(void *p); void *gl_malloc(int size); void *gl_zalloc(int size); +void *gl_realloc(void *p, int size); } // end of namespace TinyGL