~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to agraph/utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This software may only be used by you under license from AT&T Corp.
 
3
    ("AT&T").  A copy of AT&T's Source Code Agreement is available at
 
4
    AT&T's Internet website having the URL:
 
5
    <http://www.research.att.com/sw/tools/graphviz/license/source.html>
 
6
    If you received this software without first entering into a license
 
7
    with AT&T, you have an infringing copy of this software and cannot use
 
8
    it without violating AT&T's intellectual property rights.
 
9
*/
 
10
#pragma prototyped
 
11
 
 
12
#include <aghdr.h>
 
13
 
 
14
#ifdef DMALLOC
 
15
#include "dmalloc.h"
 
16
#endif
 
17
 
 
18
static Agraph_t         *Ag_dictop_G;
 
19
 
 
20
/* only indirect call through dtopen() is expected */
 
21
void *agdictobjmem(Dict_t *dict, Void_t *p, size_t size, Dtdisc_t *disc)
 
22
{
 
23
        Agraph_t        *g;
 
24
 
 
25
        NOTUSED(dict);
 
26
        NOTUSED(disc);
 
27
        g = Ag_dictop_G;
 
28
        if (g) {
 
29
                if (p) agfree(g,p);
 
30
                else return agalloc(g,size);
 
31
        }
 
32
        else {
 
33
                if (p) free(p);
 
34
                else return malloc(size);
 
35
        }
 
36
        return NIL(void*);
 
37
}
 
38
 
 
39
void agdictobjfree(Dict_t *dict, Void_t *p, Dtdisc_t *disc)
 
40
{
 
41
        Agraph_t        *g;
 
42
 
 
43
        NOTUSED(dict); NOTUSED(disc);
 
44
        g = Ag_dictop_G;
 
45
        if (g) agfree(g,p);
 
46
        else free(p);
 
47
}
 
48
 
 
49
Dict_t *agdtopen(Agraph_t *g, Dtdisc_t *disc, Dtmethod_t *method)
 
50
{
 
51
        Dtmemory_f      memf;
 
52
        Dict_t          *d;
 
53
 
 
54
        memf = disc->memoryf;
 
55
        disc->memoryf = agdictobjmem;
 
56
        Ag_dictop_G = g;
 
57
        d = dtopen(disc,method);
 
58
        disc->memoryf = memf;
 
59
        return d;
 
60
}
 
61
 
 
62
long agdtdelete(Agraph_t *g, Dict_t *dict, void *obj)
 
63
{
 
64
        Ag_dictop_G = g;
 
65
        return (long)dtdelete(dict,obj);
 
66
}
 
67
 
 
68
int agobjfinalize(Void_t *obj)
 
69
{
 
70
        agfree(Ag_dictop_G,obj);
 
71
        return 0;
 
72
}
 
73
 
 
74
void agdtclose(Agraph_t *g, Dict_t *dict)
 
75
{
 
76
        Dtmemory_f      memf;
 
77
        Dtdisc_t        *disc;
 
78
        
 
79
        disc = dtdisc(dict,NIL(Dtdisc_t*),0);
 
80
        memf = disc->memoryf;
 
81
        disc->memoryf = agdictobjmem;
 
82
        Ag_dictop_G = g;
 
83
        if (dtclose(dict)) abort();
 
84
        disc->memoryf = memf;
 
85
}
 
86
 
 
87
void agdtdisc(Agraph_t *g, Dict_t *dict, Dtdisc_t *disc)
 
88
{
 
89
        if (disc && (dtdisc(dict,NIL(Dtdisc_t*),0) != disc)) {
 
90
                agflatten(g,FALSE);
 
91
                dtdisc(dict,disc,0);
 
92
        }
 
93
        /* else unchanged, disc is same as old disc */
 
94
}