Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
gvcontext.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11/*
12 A gvcontext is a single instance of a GVC_t data structure providing
13 for a set of plugins for processing one graph at a time, and a job
14 description provividing for a sequence of graph jobs.
15
16 Sometime in the future it may become the basis for a thread.
17 */
18
19#include "config.h"
20
21#include <stdlib.h>
22
23#include "builddate.h"
24#include <cgraph/alloc.h>
25#include <common/render.h>
26#include <common/types.h>
27#include <gvc/gvplugin.h>
28#include <gvc/gvcjob.h>
29#include <gvc/gvcint.h>
30#include <gvc/gvcproc.h>
31#include <gvc/gvc.h>
32
33/* from common/textspan.c */
34extern void textfont_dict_close(GVC_t *gvc);
35
36/* from common/globals.c */
37extern int graphviz_errors;
38
39static char *LibInfo[] = {
40 "graphviz", /* Program */
41 PACKAGE_VERSION, /* Version */
42 BUILDDATE /* Build Date */
43};
44
45GVC_t *gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
46{
47 GVC_t *gvc = gv_alloc(sizeof(GVC_t));
48
51 gvc->common.builtins = builtins;
52 gvc->common.demand_loading = demand_loading;
53
54 return gvc;
55}
56
62
63
65{
66 GVG_t *gvg, *gvg_next;
67 gvplugin_package_t *package, *package_next;
68 gvplugin_available_t *api, *api_next;
69
71 gvg_next = gvc->gvgs;
72 while ((gvg = gvg_next)) {
73 gvg_next = gvg->next;
74 free(gvg);
75 }
76 package_next = gvc->packages;
77 while ((package = package_next)) {
78 package_next = package->next;
79 free(package->path);
80 free(package->name);
81 free(package);
82 }
87 for (size_t i = 0; i < sizeof(gvc->apis) / sizeof(gvc->apis[0]); ++i) {
88 for (api = gvc->apis[i]; api != NULL; api = api_next) {
89 api_next = api->next;
90 free(api->typestr);
91 free(api);
92 }
93 }
94 free(gvc);
95 return (graphviz_errors + agerrors());
96}
97
99{
100 GVC_t *gvc = gv_alloc(sizeof(GVC_t));
101
102 gvc->common = gvc0->common;
103 memcpy (&gvc->apis, &gvc0->apis, sizeof(gvc->apis));
104 memcpy (&gvc->api, &gvc0->api, sizeof(gvc->api));
105 gvc->packages = gvc0->packages;
106
107 return gvc;
108}
109
111{
113 free(gvc);
114}
115
Memory allocation wrappers that exit on failure.
static void * gv_alloc(size_t size)
Definition alloc.h:47
void emit_once_reset(void)
Definition emit.c:3459
void free(void *)
node NULL
Definition grammar.y:149
void agerrorf(const char *fmt,...)
Definition agerror.c:165
int agerrors(void)
Definition agerror.c:181
GVC_t * gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
Definition gvcontext.c:45
void gvFinalize(GVC_t *gvc)
Definition gvcontext.c:57
int gvFreeContext(GVC_t *gvc)
Definition gvcontext.c:64
Graphviz context library.
static char * LibInfo[]
Definition gvcontext.c:39
int graphviz_errors
Definition globals.h:56
GVC_t * gvCloneGVC(GVC_t *gvc0)
Definition gvcontext.c:98
void textfont_dict_close(GVC_t *gvc)
Definition textspan.c:165
void gvFreeCloneGVC(GVC_t *gvc)
Definition gvcontext.c:110
void gvrender_end_job(GVJ_t *job)
Definition gvrender.c:116
void gvjobs_delete(GVC_t *gvc)
Definition gvjobs.c:104
GVC_t * gvc
Definition htmlparse.c:99
const lt_symlist_t * builtins
Definition gvcommon.h:31
char ** info
Definition gvcommon.h:20
void(* errorfn)(const char *fmt,...)
Definition gvcommon.h:24
int demand_loading
Definition gvcommon.h:32
Definition gvcint.h:80
char * config_path
Definition gvcint.h:83
GVG_t * gvgs
Definition gvcint.h:91
GVJ_t * active_jobs
Definition gvcint.h:123
GVCOMMON_t common
Definition gvcint.h:81
gvplugin_package_t * packages
Definition gvcint.h:100
char ** input_filenames
Definition gvcint.h:87
gvplugin_available_t * apis[APIS]
Definition gvcint.h:97
gvplugin_available_t * api[APIS]
Definition gvcint.h:98
Definition gvcint.h:69
GVG_t * next
Definition gvcint.h:71
gvplugin_available_t * next
Definition gvcint.h:60
gvplugin_package_t * next
Definition gvcint.h:54
graphs, nodes and edges info: Agraphinfo_t, Agnodeinfo_t and Agedgeinfo_t