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

« back to all changes in this revision

Viewing changes to cdt/dtopen.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
#include        "dthdr.h"
 
11
 
 
12
#ifdef DMALLOC
 
13
#include "dmalloc.h"
 
14
#endif
 
15
 
 
16
static char*     Version = "\n@(#)cdt (AT&T Labs - kpv) 1999-11-01\0\n";
 
17
 
 
18
/*      Make a new dictionary
 
19
**
 
20
**      Written by Kiem-Phong Vo (5/25/96)
 
21
*/
 
22
 
 
23
#if __STD_C
 
24
Dt_t* dtopen(Dtdisc_t* disc, Dtmethod_t* meth)
 
25
#else
 
26
Dt_t*   dtopen(disc, meth)
 
27
Dtdisc_t*       disc;
 
28
Dtmethod_t*     meth;
 
29
#endif
 
30
{
 
31
        Dt_t*           dt = (Dt_t*)Version;    /* shut-up unuse warning */
 
32
        reg int         e;
 
33
        Dtdata_t*       data;
 
34
 
 
35
        if(!disc || !meth)
 
36
                return NIL(Dt_t*);
 
37
 
 
38
        /* allocate space for dictionary */
 
39
        if(!(dt = (Dt_t*) malloc(sizeof(Dt_t))))
 
40
                return NIL(Dt_t*);
 
41
 
 
42
        /* initialize all absolutely private data */
 
43
        dt->searchf = NIL(Dtsearch_f);
 
44
        dt->meth = NIL(Dtmethod_t*);
 
45
        dt->disc = NIL(Dtdisc_t*);
 
46
        dtdisc(dt,disc,0);
 
47
        dt->nview = 0;
 
48
        dt->view = dt->walk = NIL(Dt_t*);
 
49
 
 
50
        if(disc->eventf)
 
51
        {       /* if shared/persistent dictionary, get existing data */
 
52
                data = NIL(Dtdata_t*);
 
53
                if((e = (*disc->eventf)(dt,DT_OPEN,(Void_t*)(&data),disc)) != 0)
 
54
                {       if(e < 0 || !data || !(data->type&meth->type) )
 
55
                        {       free((Void_t*)dt);
 
56
                                return NIL(Dt_t*);
 
57
                        }
 
58
                        else    goto done;
 
59
                }
 
60
        }
 
61
 
 
62
        /* allocate sharable data */
 
63
        data = (Dtdata_t*)(dt->memoryf)(dt,NIL(Void_t*),sizeof(Dtdata_t),disc);
 
64
        if(!data)
 
65
        {       free((Void_t*)dt);
 
66
                return NIL(Dt_t*);
 
67
        }
 
68
        data->type = meth->type;
 
69
        data->here = NIL(Dtlink_t*);
 
70
        data->htab = NIL(Dtlink_t**);
 
71
        data->ntab = data->size = data->loop = 0;
 
72
 
 
73
done:
 
74
        dt->data = data;
 
75
        dt->searchf = meth->searchf;
 
76
        dt->meth = meth;
 
77
 
 
78
        return dt;
 
79
}
 
80
 
 
81
#if __hppa
 
82
 
 
83
/*
 
84
 * some dll implementations forget that data symbols
 
85
 * need address resolution too
 
86
 */
 
87
 
 
88
#if __STD_C
 
89
int _dt_dynamic_data(void)
 
90
#else
 
91
int _dt_dynamic_data()
 
92
#endif
 
93
{
 
94
        return (Dtset != 0) + (Dtlist != 0) + (Dttree != 0);
 
95
}
 
96
 
 
97
#endif /* __hppa */