[Scummvm-git-logs] scummvm master -> 4b2e3e67266ae4ed153ccbf98b2e5b94de85353b
ccawley2011
noreply at scummvm.org
Fri Feb 3 22:07:07 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4b2e3e6726 TINYGL: Use realloc to increase the size of the vertex array
Commit: 4b2e3e67266ae4ed153ccbf98b2e5b94de85353b
https://github.com/scummvm/scummvm/commit/4b2e3e67266ae4ed153ccbf98b2e5b94de85353b
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-03T22:06:53Z
Commit Message:
TINYGL: Use realloc to increase the size of the vertex array
Changed paths:
graphics/tinygl/memory.cpp
graphics/tinygl/vertex.cpp
graphics/tinygl/zbuffer.h
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
More information about the Scummvm-git-logs
mailing list