Graphviz
14.1.2~dev.20260123.1158
Loading...
Searching...
No Matches
dtmethod.c
Go to the documentation of this file.
1
#include "config.h"
2
3
#include <
cdt/dthdr.h
>
4
#include <stdlib.h>
5
6
/* Change search method.
7
**
8
** Written by Kiem-Phong Vo (05/25/96)
9
*/
10
11
Dtmethod_t
*
dtmethod
(
Dt_t
* dt,
Dtmethod_t
* meth)
12
{
13
Dtlink_t
*list, *r;
14
Dtdisc_t
*
disc
= dt->
disc
;
15
Dtmethod_t
* oldmeth = dt->
meth
;
16
17
if
(!meth || meth->
type
== oldmeth->
type
)
18
return
oldmeth;
19
20
/* get the list of elements */
21
list =
dtflatten
(dt);
22
23
if
(dt->
data
.
type
&
DT_SET
)
24
{
if
(dt->
data
.
ntab
> 0)
25
free
(dt->
data
.htab);
26
dt->
data
.
ntab
= 0;
27
dt->
data
.htab =
NULL
;
28
}
29
30
dt->
data
.
here
=
NULL
;
31
dt->
data
.
type
= (dt->
data
.
type
& ~(
DT_METHODS
|
DT_FLATTEN
)) | meth->
type
;
32
dt->
meth
= meth;
33
if
(dt->
searchf
== oldmeth->
searchf
)
34
dt->
searchf
= meth->
searchf
;
35
36
if
(meth->
type
&(
DT_OSET
|
DT_OBAG
))
37
{ dt->
data
.
size
= 0;
38
while
(list)
39
{ r = list->
right
;
40
meth->
searchf
(dt, list,
DT_RENEW
);
41
list = r;
42
}
43
}
44
else
if
(oldmeth->
type
&
DT_SET
)
45
{
int
rehash;
46
if
((meth->
type
&
DT_SET
) && !(oldmeth->
type
&
DT_SET
))
47
rehash = 1;
48
else
rehash = 0;
49
50
dt->
data
.
size
= 0;
51
dt->
data
.
loop
= 0;
52
while
(list)
53
{ r = list->
right
;
54
if
(rehash)
55
{
void
* key =
_DTOBJ
(list,
disc
->
link
);
56
key =
_DTKEY
(key,
disc
->
key
,
disc
->
size
);
57
list->hash =
dtstrhash
(key,
disc
->
size
);
58
}
59
(void)meth->
searchf
(dt, list,
DT_RENEW
);
60
list = r;
61
}
62
}
63
64
return
oldmeth;
65
}
_DTKEY
#define _DTKEY(o, ky, sz)
Definition
cdt.h:169
DT_OBAG
#define DT_OBAG
Definition
cdt.h:121
DT_SET
#define DT_SET
Definition
cdt.h:119
dtflatten
CDT_API Dtlink_t * dtflatten(Dt_t *)
Definition
dtflatten.c:12
dtstrhash
CDT_API unsigned int dtstrhash(void *, int)
Definition
dtstrhash.c:23
DT_RENEW
#define DT_RENEW
Definition
cdt.h:130
DT_METHODS
#define DT_METHODS
Definition
cdt.h:122
DT_OSET
#define DT_OSET
Definition
cdt.h:120
_DTOBJ
#define _DTOBJ(e, lk)
Definition
cdt.h:167
dthdr.h
DT_FLATTEN
#define DT_FLATTEN
Definition
dthdr.h:18
dtmethod
Dtmethod_t * dtmethod(Dt_t *dt, Dtmethod_t *meth)
Definition
dtmethod.c:11
disc
static Dtdisc_t disc
Definition
exparse.y:209
free
void free(void *)
NULL
node NULL
Definition
grammar.y:181
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
Dtdata_t::loop
int loop
Definition
cdt.h:80
Dtmethod_t
Definition
cdt.h:65
Dtmethod_t::searchf
Dtsearch_f searchf
Definition
cdt.h:66
Dtmethod_t::type
int type
Definition
cdt.h:67
dt_s_
Definition
cdt.h:98
dt_s_::meth
Dtmethod_t * meth
Definition
cdt.h:102
dt_s_::searchf
Dtsearch_f searchf
Definition
cdt.h:99
dt_s_::data
Dtdata_t data
sharable data
Definition
cdt.h:101
dt_s_::disc
Dtdisc_t * disc
Definition
cdt.h:100
dtdisc_s_
Definition
cdt.h:84
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:50
dtlink_s_::right
Dtlink_t * right
Definition
cdt.h:51
lib
cdt
dtmethod.c
Generated by
1.9.8