Graphviz
13.0.0~dev.20241220.2304
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 <
common/render.h
>
25
#include <
common/types.h
>
26
#include <
gvc/gvplugin.h
>
27
#include <
gvc/gvcjob.h
>
28
#include <
gvc/gvcint.h
>
29
#include <
gvc/gvcproc.h
>
30
#include <
gvc/gvc.h
>
31
#include <
util/alloc.h
>
32
33
/* from common/textspan.c */
34
extern
void
textfont_dict_close
(
GVC_t
*
gvc
);
35
36
/* from common/globals.c */
37
extern
int
graphviz_errors
;
38
39
static
char
*
LibInfo
[] = {
40
"graphviz"
,
/* Program */
41
PACKAGE_VERSION,
/* Version */
42
BUILDDATE
/* Build Date */
43
};
44
45
GVC_t
*
gvNEWcontext
(
const
lt_symlist_t
*builtins,
int
demand_loading)
46
{
47
GVC_t
*
gvc
=
gv_alloc
(
sizeof
(
GVC_t
));
48
49
gvc
->
common
.
info
=
LibInfo
;
50
gvc
->
common
.
errorfn
=
agerrorf
;
51
gvc
->
common
.
builtins
= builtins;
52
gvc
->
common
.
demand_loading
= demand_loading;
53
54
return
gvc
;
55
}
56
57
void
gvFinalize
(
GVC_t
*
gvc
)
58
{
59
if
(
gvc
->
active_jobs
)
60
gvrender_end_job
(
gvc
->
active_jobs
);
61
}
62
63
64
int
gvFreeContext
(
GVC_t
*
gvc
)
65
{
66
GVG_t
*gvg, *gvg_next;
67
gvplugin_package_t
*package, *package_next;
68
gvplugin_available_t
*api, *api_next;
69
70
emit_once_reset
();
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
}
83
gvjobs_delete
(
gvc
);
84
free
(
gvc
->
config_path
);
85
free
(
gvc
->
input_filenames
);
86
textfont_dict_close
(
gvc
);
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
98
GVC_t
*
gvCloneGVC
(
GVC_t
* gvc0)
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
110
void
gvFreeCloneGVC
(
GVC_t
*
gvc
)
111
{
112
gvjobs_delete
(
gvc
);
113
free
(
gvc
);
114
}
115
alloc.h
Memory allocation wrappers that exit on failure.
gv_alloc
static void * gv_alloc(size_t size)
Definition
alloc.h:47
emit_once_reset
void emit_once_reset(void)
Definition
emit.c:3440
free
void free(void *)
NULL
node NULL
Definition
grammar.y:163
agerrorf
void agerrorf(const char *fmt,...)
Definition
agerror.c:165
agerrors
int agerrors(void)
Definition
agerror.c:181
gvNEWcontext
GVC_t * gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
Definition
gvcontext.c:45
gvFinalize
void gvFinalize(GVC_t *gvc)
Definition
gvcontext.c:57
gvFreeContext
int gvFreeContext(GVC_t *gvc)
Definition
gvcontext.c:64
gvc
static GVC_t * gvc
Definition
gv.cpp:23
gvc.h
Graphviz context library.
gvcint.h
gvcjob.h
LibInfo
static char * LibInfo[]
Definition
gvcontext.c:39
graphviz_errors
int graphviz_errors
Definition
globals.h:53
gvCloneGVC
GVC_t * gvCloneGVC(GVC_t *gvc0)
Definition
gvcontext.c:98
textfont_dict_close
void textfont_dict_close(GVC_t *gvc)
Definition
textspan.c:165
gvFreeCloneGVC
void gvFreeCloneGVC(GVC_t *gvc)
Definition
gvcontext.c:110
gvcproc.h
gvrender_end_job
void gvrender_end_job(GVJ_t *job)
Definition
gvrender.c:116
gvjobs_delete
void gvjobs_delete(GVC_t *gvc)
Definition
gvjobs.c:104
gvplugin.h
render.h
GVCOMMON_s::builtins
const lt_symlist_t * builtins
Definition
gvcommon.h:31
GVCOMMON_s::info
char ** info
Definition
gvcommon.h:20
GVCOMMON_s::errorfn
void(* errorfn)(const char *fmt,...)
Definition
gvcommon.h:24
GVCOMMON_s::demand_loading
int demand_loading
Definition
gvcommon.h:32
GVC_s
Definition
gvcint.h:80
GVC_s::config_path
char * config_path
Definition
gvcint.h:83
GVC_s::gvgs
GVG_t * gvgs
Definition
gvcint.h:91
GVC_s::active_jobs
GVJ_t * active_jobs
Definition
gvcint.h:123
GVC_s::common
GVCOMMON_t common
Definition
gvcint.h:81
GVC_s::packages
gvplugin_package_t * packages
Definition
gvcint.h:100
GVC_s::input_filenames
char ** input_filenames
Definition
gvcint.h:87
GVC_s::apis
gvplugin_available_t * apis[APIS]
Definition
gvcint.h:97
GVC_s::api
gvplugin_available_t * api[APIS]
Definition
gvcint.h:98
GVG_s
Definition
gvcint.h:69
GVG_s::next
GVG_t * next
Definition
gvcint.h:71
gvplugin_available_s
Definition
gvcint.h:59
gvplugin_available_s::typestr
char * typestr
Definition
gvcint.h:61
gvplugin_available_s::next
gvplugin_available_t * next
Definition
gvcint.h:60
gvplugin_package_s
Definition
gvcint.h:53
gvplugin_package_s::next
gvplugin_package_t * next
Definition
gvcint.h:54
gvplugin_package_s::name
char * name
Definition
gvcint.h:56
gvplugin_package_s::path
char * path
Definition
gvcint.h:55
lt_symlist_t
Definition
gvcext.h:39
types.h
graphs, nodes and edges info: Agraphinfo_t, Agnodeinfo_t and Agedgeinfo_t
lib
gvc
gvcontext.c
Generated by
1.9.8