Graphviz
13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
dtdisc.c
Go to the documentation of this file.
1
#include <
cdt/dthdr.h
>
2
#include <stddef.h>
3
4
/* Change discipline.
5
** dt : dictionary
6
** disc : discipline
7
**
8
** Written by Kiem-Phong Vo (5/26/96)
9
*/
10
11
Dtdisc_t
*
dtdisc
(
Dt_t
*dt,
Dtdisc_t
*
disc
) {
12
Dtsearch_f
searchf;
13
Dtlink_t
*r, *t;
14
char
* k;
15
Dtdisc_t
* old;
16
17
if
(!(old = dt->
disc
) )
/* initialization call from dtopen() */
18
{ dt->
disc
=
disc
;
19
return
disc
;
20
}
21
22
if
(!
disc
)
/* only want to know current discipline */
23
return
old;
24
25
searchf = dt->
meth
->
searchf
;
26
27
UNFLATTEN
(dt);
28
29
dt->
disc
=
disc
;
30
31
r =
dtflatten
(dt);
32
dt->
data
.
type
&= ~DT_FLATTEN;
33
dt->
data
.
here
=
NULL
;
34
dt->
data
.
size
= 0;
35
36
if
(dt->
data
.
type
&
DT_SET
)
37
{
Dtlink_t
**
s
, **ends;
38
ends = (
s
= dt->
data
.htab) + dt->
data
.
ntab
;
39
while
(
s
< ends)
40
*
s
++ =
NULL
;
41
}
42
43
/* reinsert them */
44
while
(r)
45
{ t = r->
right
;
46
k =
_DTOBJ
(r,
disc
->
link
);
47
k =
_DTKEY
(k,
disc
->
key
,
disc
->
size
);
48
r->hash =
dtstrhash
(k,
disc
->
size
);
49
(void)searchf(dt, r,
DT_RENEW
);
50
r = t;
51
}
52
53
return
old;
54
}
_DTKEY
#define _DTKEY(o, ky, sz)
Definition
cdt.h:169
DT_SET
#define DT_SET
Definition
cdt.h:120
dtflatten
CDT_API Dtlink_t * dtflatten(Dt_t *)
Definition
dtflatten.c:10
dtstrhash
CDT_API unsigned int dtstrhash(void *, int)
Definition
dtstrhash.c:21
DT_RENEW
#define DT_RENEW
Definition
cdt.h:131
_DTOBJ
#define _DTOBJ(e, lk)
Definition
cdt.h:168
Dtsearch_f
void *(* Dtsearch_f)(Dt_t *, void *, int)
Definition
cdt.h:45
dtdisc
Dtdisc_t * dtdisc(Dt_t *dt, Dtdisc_t *disc)
Definition
dtdisc.c:11
dthdr.h
UNFLATTEN
#define UNFLATTEN(dt)
Definition
dthdr.h:27
disc
static Dtdisc_t disc
Definition
exparse.y:209
NULL
node NULL
Definition
grammar.y:163
Dtdata_t::size
int size
Definition
cdt.h:79
Dtdata_t::here
Dtlink_t * here
Definition
cdt.h:73
Dtdata_t::type
int type
Definition
cdt.h:72
Dtdata_t::ntab
int ntab
Definition
cdt.h:78
Dtmethod_t::searchf
Dtsearch_f searchf
Definition
cdt.h:66
dt_s_
Definition
cdt.h:100
dt_s_::meth
Dtmethod_t * meth
Definition
cdt.h:103
dt_s_::data
Dtdata_t data
sharable data
Definition
cdt.h:102
dt_s_::disc
Dtdisc_t * disc
Definition
cdt.h:101
dtdisc_s_
Definition
cdt.h:85
dtdisc_s_::key
int key
Definition
cdt.h:85
dtdisc_s_::size
int size
Definition
cdt.h:86
dtdisc_s_::link
int link
Definition
cdt.h:87
dtlink_s_
Definition
cdt.h:51
dtlink_s_::right
Dtlink_t * right
Definition
cdt.h:51
s
Definition
grammar.c:93
lib
cdt
dtdisc.c
Generated by
1.9.8