]> granicus.if.org Git - graphviz/commitdiff
smyrna create_color_theme: use cgraph wrapper for allocations
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 2 Sep 2022 01:17:10 +0000 (18:17 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 2 Sep 2022 01:17:10 +0000 (18: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.

cmd/smyrna/viewport.c

index 96a227dd05a6c4e263fc758c96d2c7396ae5a177..1edacb35e3095cade908e043d4d5b7f9acff9716 100644 (file)
@@ -723,19 +723,17 @@ static colordata palette[] = {
 
 static colorschemaset *create_color_theme(int themeid)
 {
-    colorschemaset *s;
-
     if (themeid < 0 || (int)NUM_SCHEMES <= themeid) {
        fprintf (stderr, "colorschemaset: illegal themeid %d\n", themeid);
        return view->colschms;
     }
 
-    s = NEW(colorschemaset);
+    colorschemaset *s = gv_alloc(sizeof(colorschemaset));
     if (view->colschms)
        clear_color_theme(view->colschms);
 
     s->schemacount = palette[themeid].cnt;
-    s->s = N_NEW(s->schemacount,colorschema);
+    s->s = gv_calloc(s->schemacount, sizeof(colorschema));
     set_color_theme_color(s, palette[themeid].colors);
 
     return s;