Graphviz  2.35.20130930.0449
gvcontext.c
Go to the documentation of this file.
1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 /*
15  A gvcontext is a single instance of a GVC_t data structure providing
16  for a set of plugins for processing one graph at a time, and a job
17  description provividing for a sequence of graph jobs.
18 
19  Sometime in the future it may become the basis for a thread.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include <stdlib.h>
27 
28 #include "builddate.h"
29 #include "types.h"
30 #include "gvplugin.h"
31 #include "gvcjob.h"
32 #include "gvcint.h"
33 #include "gvcproc.h"
34 #include "gvc.h"
35 
36 /* from common/utils.c */
37 extern void *zmalloc(size_t);
38 
39 /* from common/emit.c */
40 extern void emit_once_reset(void);
41 
42 /* from common/globals.c */
43 extern int graphviz_errors;
44 
45 static char *LibInfo[] = {
46  "graphviz", /* Program */
47  VERSION, /* Version */
48  BUILDDATE /* Build Date */
49 };
50 
51 GVC_t *gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
52 {
53  GVC_t *gvc = zmalloc(sizeof(GVC_t));
54 
55  if (gvc) {
56  gvc->common.info = LibInfo;
57  gvc->common.errorfn = agerrorf;
58  gvc->common.builtins = builtins;
59  gvc->common.demand_loading = demand_loading;
60  }
61  return gvc;
62 }
63 
64 void gvFinalize(GVC_t * gvc)
65 {
66  if (gvc->active_jobs)
68 }
69 
70 
71 int gvFreeContext(GVC_t * gvc)
72 {
73  GVG_t *gvg, *gvg_next;
74  gvplugin_package_t *package, *package_next;
75 
77  gvg_next = gvc->gvgs;
78  while ((gvg = gvg_next)) {
79  gvg_next = gvg->next;
80  free(gvg);
81  }
82  package_next = gvc->packages;
83  while ((package = package_next)) {
84  package_next = package->next;
85  free(package->path);
86  free(package->name);
87  free(package);
88  }
89  gvjobs_delete(gvc);
90  if (gvc->config_path)
91  free(gvc->config_path);
92  if (gvc->input_filenames)
93  free(gvc->input_filenames);
94  free(gvc);
95  return (graphviz_errors + agerrors());
96 }