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
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}
#define _DTKEY(o, ky, sz)
Definition cdt.h:169
#define DT_SET
Definition cdt.h:120
CDT_API Dtlink_t * dtflatten(Dt_t *)
Definition dtflatten.c:10
CDT_API unsigned int dtstrhash(void *, int)
Definition dtstrhash.c:21
#define DT_RENEW
Definition cdt.h:131
#define _DTOBJ(e, lk)
Definition cdt.h:168
void *(* Dtsearch_f)(Dt_t *, void *, int)
Definition cdt.h:45
Dtdisc_t * dtdisc(Dt_t *dt, Dtdisc_t *disc)
Definition dtdisc.c:11
#define UNFLATTEN(dt)
Definition dthdr.h:27
static Dtdisc_t disc
Definition exparse.y:209
node NULL
Definition grammar.y:163
int size
Definition cdt.h:79
Dtlink_t * here
Definition cdt.h:73
int type
Definition cdt.h:72
int ntab
Definition cdt.h:78
Dtsearch_f searchf
Definition cdt.h:66
Definition cdt.h:100
Dtmethod_t * meth
Definition cdt.h:103
Dtdata_t data
sharable data
Definition cdt.h:102
Dtdisc_t * disc
Definition cdt.h:101
int key
Definition cdt.h:85
int size
Definition cdt.h:86
int link
Definition cdt.h:87
Definition grammar.c:93