~ubuntu-branches/ubuntu/precise/graphviz/precise-security

« back to all changes in this revision

Viewing changes to lib/gvc/gvcontext.c

  • Committer: Bazaar Package Importer
  • Author(s): David Claughton
  • Date: 2010-03-24 22:45:18 UTC
  • mfrom: (1.2.7 upstream) (6.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100324224518-do441tthbqjaqjzd
Tags: 2.26.3-4
Add patch to fix segfault in circo. Backported from upstream snapshot
release.  Thanks to Francis Russell for his work on this.
(Closes: #575255)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: gvcontext.c,v 1.20 2007/11/02 20:30:28 ellson Exp $ $Revision: 1.20 $ */
 
1
/* $Id: gvcontext.c,v 1.36 2009/10/04 20:15:42 ellson Exp $ $Revision: 1.36 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
26
26
#include "config.h"
27
27
#endif
28
28
 
29
 
#include        "types.h"
30
 
#include        "graph.h"
31
 
#include        "gvplugin.h"
32
 
#include        "gvcjob.h"
33
 
#include        "gvcint.h"
34
 
#include        "gvcproc.h"
 
29
#include <stdlib.h>
 
30
 
 
31
#include "builddate.h"
 
32
#include "types.h"
 
33
#include "gvplugin.h"
 
34
#include "gvcjob.h"
 
35
#include "gvcint.h"
 
36
#include "gvcproc.h"
 
37
#include "gvc.h"
35
38
 
36
39
/* from common/utils.c */
37
40
extern void *zmalloc(size_t);
42
45
/* from common/globals.c */
43
46
extern int graphviz_errors;
44
47
 
45
 
GVC_t *gvNEWcontext(char **info, char *user)
 
48
static char *LibInfo[] = {
 
49
    "graphviz",         /* Program */
 
50
    VERSION,            /* Version */
 
51
    BUILDDATE           /* Build Date */
 
52
};
 
53
 
 
54
GVC_t *gvNEWcontext(const lt_symlist_t *builtins, int demand_loading)
46
55
{
47
56
    GVC_t *gvc = zmalloc(sizeof(GVC_t));
48
57
 
49
58
    if (gvc) {
50
 
        gvc->common.info = info;
51
 
        gvc->common.user = user;
 
59
        gvc->common.info = LibInfo;
52
60
        gvc->common.errorfn = agerrorf;
 
61
        gvc->common.builtins = builtins;
 
62
        gvc->common.demand_loading = demand_loading;
53
63
    }
54
64
    return gvc;
55
65
}
56
66
 
 
67
void gvFinalize(GVC_t * gvc)
 
68
{
 
69
    if (gvc->active_jobs)
 
70
        gvrender_end_job(gvc->active_jobs);
 
71
}
 
72
 
 
73
 
57
74
int gvFreeContext(GVC_t * gvc)
58
75
{
59
76
    GVG_t *gvg, *gvg_next;
 
77
    gvplugin_package_t *package, *package_next;
60
78
 
61
 
    if (gvc->active_jobs)
62
 
        gvrender_end_job(gvc->active_jobs);
63
79
    emit_once_reset();
64
80
    gvg_next = gvc->gvgs;
65
81
    while ((gvg = gvg_next)) {
66
82
        gvg_next = gvg->next;
67
83
        free(gvg);
68
84
    }
 
85
    package_next = gvc->packages;
 
86
    while ((package = package_next)) {
 
87
        package_next = package->next;
 
88
        free(package->path);
 
89
        free(package->name);
 
90
        free(package);
 
91
    }
69
92
    gvjobs_delete(gvc);
70
93
    if (gvc->config_path)
71
94
        free(gvc->config_path);