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

« back to all changes in this revision

Viewing changes to lib/gvc/gvlayout.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: gvlayout.c,v 1.25 2006/12/07 22:49:36 erg Exp $ $Revision: 1.25 $ */
 
1
/* $Id: gvlayout.c,v 1.38 2009/07/20 20:16:46 erg Exp $ $Revision: 1.38 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
26
26
#include "const.h"
27
27
#include "gvplugin_layout.h"
28
28
#include "gvcint.h"
 
29
#if WITH_CGRAPH
 
30
#include "cgraph.h"
 
31
#else
29
32
#include "graph.h"
 
33
#endif
30
34
#include "gvcproc.h"
31
 
 
32
 
extern void graph_init(graph_t *g, boolean use_rankdir);
33
 
extern void graph_cleanup(graph_t *g);
34
 
 
35
 
int gvlayout_select(GVC_t * gvc, char *layout)
 
35
#include "gvc.h"
 
36
 
 
37
extern void graph_init(Agraph_t *g, boolean use_rankdir);
 
38
extern void graph_cleanup(Agraph_t *g);
 
39
 
 
40
int gvlayout_select(GVC_t * gvc, const char *layout)
36
41
{
37
42
    gvplugin_available_t *plugin;
38
43
    gvplugin_installed_t *typeptr;
54
59
 * Check that the root graph has been initialized. If not, initialize it.
55
60
 * Return 0 on success.
56
61
 */
57
 
int gvLayoutJobs(GVC_t * gvc, graph_t * g)
 
62
int gvLayoutJobs(GVC_t * gvc, Agraph_t * g)
58
63
{
59
 
    gvlayout_engine_t *gvle = gvc->layout.engine;
60
 
 
 
64
    gvlayout_engine_t *gvle;
 
65
    char *p;
 
66
    int rc;
 
67
 
 
68
#ifdef WITH_CGRAPH
 
69
    agbindrec(g, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE);
 
70
#endif
 
71
    GD_gvc(g) = gvc;
 
72
    if (g != agroot(g))
 
73
        GD_gvc(agroot(g)) = gvc;
 
74
 
 
75
    if ((p = agget(g, "layout"))) {
 
76
        rc = gvlayout_select(gvc, p);
 
77
        if (rc == NO_SUPPORT) {
 
78
            agerr (AGERR, "Layout type: \"%s\" not recognized. Use one of:%s\n",
 
79
                p, gvplugin_list(gvc, API_layout, p));
 
80
            return -1;
 
81
        }
 
82
    }
 
83
 
 
84
    gvle = gvc->layout.engine;
61
85
    if (! gvle)
62
86
        return -1;
63
87
 
64
 
    GD_gvc(g) = gvc;
65
 
    if (g != g->root) GD_gvc(g->root) = gvc;
66
88
    graph_init(g, gvc->layout.features->flags & LAYOUT_USES_RANKDIR);
67
 
    GD_drawing(g->root) = GD_drawing(g);
 
89
    GD_drawing(agroot(g)) = GD_drawing(g);
68
90
    if (gvle && gvle->layout) {
69
91
        gvle->layout(g);
 
92
 
 
93
 
70
94
        if (gvle->cleanup)
71
95
            GD_cleanup(g) = gvle->cleanup;
72
96
    }
80
104
 * Then, if the root graph has not been cleaned up, clean it up and reset.
81
105
 * Only the root graph has GD_drawing non-null.
82
106
 */
83
 
int gvFreeLayout(GVC_t * gvc, graph_t * g)
 
107
int gvFreeLayout(GVC_t * gvc, Agraph_t * g)
84
108
{
85
109
    if (GD_cleanup(g)) {
86
110
        (GD_cleanup(g))(g);