From 578e147ba19fa783c5046fe0924aa043b68a2882 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 16 Sep 2022 17:26:38 -0700 Subject: [PATCH] glcomp glCompSetAddNewTexture: use cgraph wrappers for allocation The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h wrappers except (1) they are header-only and (2) they live in a directory (cgraph) that is at the root of the dependency tree. The long term plan is to replace all use of lib/common/memory.h with lib/cgraph/alloc.h. --- lib/glcomp/glcomptexture.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/glcomp/glcomptexture.c b/lib/glcomp/glcomptexture.c index 429a91244..05a170fc8 100644 --- a/lib/glcomp/glcomptexture.c +++ b/lib/glcomp/glcomptexture.c @@ -8,6 +8,7 @@ * Contributors: Details at https://graphviz.org *************************************************************************/ +#include #include #include @@ -18,7 +19,6 @@ static glCompTex *glCompSetAddNewTexture(glCompSet * s, int width, int is2D) { int Er, offset, ind; - glCompTex *t; unsigned char *tarData; unsigned char *srcData; @@ -26,7 +26,7 @@ static glCompTex *glCompSetAddNewTexture(glCompSet * s, int width, return NULL; Er = 0; - t = NEW(glCompTex); + glCompTex *t = gv_alloc(sizeof(glCompTex)); if (!is2D) { /*use opengl texture */ glEnable(GL_TEXTURE_2D); glShadeModel(GL_FLAT); @@ -51,7 +51,7 @@ static glCompTex *glCompSetAddNewTexture(glCompSet * s, int width, } } if (is2D && !Er) { - t->data = N_NEW(4 * width * height, unsigned char); + t->data = gv_calloc(4 * width * height, sizeof(unsigned char)); offset = 4; //RGBA mod,TO DO implement other modes /*data upside down because of pango gl coord system */ for (ind = 0; ind < height; ind++) { @@ -71,9 +71,9 @@ static glCompTex *glCompSetAddNewTexture(glCompSet * s, int width, t->height = (GLfloat) height; if(s) { - s->textureCount++; s->textures = - realloc(s->textures, s->textureCount * sizeof(glCompTex *)); + gv_recalloc(s->textures, s->textureCount, s->textureCount + 1, sizeof(glCompTex *)); + s->textureCount++; s->textures[s->textureCount - 1] = t; } return t; -- 2.40.0