Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-07-31 17:54:58 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-07-31 19:21:23 +0300
commit3ecba657bb79e010cffae4110ee74a063429f7ae (patch)
tree90acd47396987f603c853dfb1d8f1a81816e273b /source/blender/gpu/intern/gpu_vertex_buffer.c
parent9b817bc168903f9c44c2464b9b2f671ddf465f06 (diff)
GPU: Replace malloc/calloc/realloc/free with MEM_* counterpart
Diffstat (limited to 'source/blender/gpu/intern/gpu_vertex_buffer.c')
-rw-r--r--source/blender/gpu/intern/gpu_vertex_buffer.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c
index d605378bf0e..05100b8a23f 100644
--- a/source/blender/gpu/intern/gpu_vertex_buffer.c
+++ b/source/blender/gpu/intern/gpu_vertex_buffer.c
@@ -29,6 +29,8 @@
* GPU vertex buffer
*/
+#include "MEM_guardedalloc.h"
+
#include "GPU_vertex_buffer.h"
#include "gpu_context_private.h"
@@ -53,7 +55,7 @@ static GLenum convert_usage_type_to_gl(GPUUsageType type)
GPUVertBuf *GPU_vertbuf_create(GPUUsageType usage)
{
- GPUVertBuf *verts = malloc(sizeof(GPUVertBuf));
+ GPUVertBuf *verts = MEM_mallocN(sizeof(GPUVertBuf), "GPUVertBuf");
GPU_vertbuf_init(verts, usage);
return verts;
}
@@ -96,9 +98,9 @@ void GPU_vertbuf_discard(GPUVertBuf *verts)
#endif
}
if (verts->data) {
- free(verts->data);
+ MEM_freeN(verts->data);
}
- free(verts);
+ MEM_freeN(verts);
}
uint GPU_vertbuf_size_get(const GPUVertBuf *verts)
@@ -123,7 +125,7 @@ void GPU_vertbuf_data_alloc(GPUVertBuf *verts, uint v_len)
}
/* discard previous data if any */
if (verts->data) {
- free(verts->data);
+ MEM_freeN(verts->data);
}
#if VRAM_USAGE
uint new_size = vertex_buffer_size(&verts->format, v_len);
@@ -131,7 +133,7 @@ void GPU_vertbuf_data_alloc(GPUVertBuf *verts, uint v_len)
#endif
verts->dirty = true;
verts->vertex_len = verts->vertex_alloc = v_len;
- verts->data = malloc(sizeof(GLubyte) * GPU_vertbuf_size_get(verts));
+ verts->data = MEM_mallocN(sizeof(GLubyte) * GPU_vertbuf_size_get(verts), "GPUVertBuf data");
}
/* resize buffer keeping existing data */
@@ -148,7 +150,7 @@ void GPU_vertbuf_data_resize(GPUVertBuf *verts, uint v_len)
#endif
verts->dirty = true;
verts->vertex_len = verts->vertex_alloc = v_len;
- verts->data = realloc(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts));
+ verts->data = MEM_reallocN(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts));
}
/* Set vertex count but does not change allocation.
@@ -250,7 +252,7 @@ static void VertBuffer_upload_data(GPUVertBuf *verts)
glBufferSubData(GL_ARRAY_BUFFER, 0, buffer_sz, verts->data);
if (verts->usage == GPU_USAGE_STATIC) {
- free(verts->data);
+ MEM_freeN(verts->data);
verts->data = NULL;
}
verts->dirty = false;