]> granicus.if.org Git - graphviz/commitdiff
glcomp glCompSetAddNewTexture: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Sep 2022 00:26:38 +0000 (17:26 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 21 Sep 2022 00:17:10 +0000 (17:17 -0700)
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

index 429a91244f5a9297f44cbf3bc903f9d1c7df8cf4..05a170fc838b041e103618b675c53402fcd44fc2 100644 (file)
@@ -8,6 +8,7 @@
  * Contributors: Details at https://graphviz.org
  *************************************************************************/
 
+#include <cgraph/alloc.h>
 #include <glcomp/glcomptexture.h>
 #include <glcomp/glpangofont.h>
 
@@ -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;