1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#ifndef _ll_delete
#define _ll_delete free
#endif
#ifndef _ll_ffirst
#define _ll_ffirst _cat(first_,_ll_rec)
#endif
#ifndef _ll_flast
#define _ll_flast _cat(last_,_ll_rec)
#endif
#ifndef _ll_fnext
#define _ll_fnext _cat(next_,_ll_rec)
#endif
#ifndef _ll_dropfn
#define _ll_dropfn _cat(_cat(_ll_ns,_),_cat(drop_, _ll_rec))
#endif
#ifndef _ll_pushfn
#define _ll_pushfn _cat(_cat(_ll_ns,_),_cat(push_, _ll_rec))
#endif
void _ll_dropfn
(_ll_box* box, _ll_obj* obj) {
if(box -> _ll_ffirst == obj) {
if(box -> _ll_flast == obj) {
box -> _ll_ffirst = box -> _ll_flast = null;
} else {
box -> _ll_ffirst = obj -> _ll_fnext;
}
} else {
................................................................................
}
}
_fatal("BUG in elt deletion routine");
found2 :;
}
}
_ll_delete (obj);
}
#undef _ll_ffirst
#undef _ll_flast
#undef _ll_ns
#undef _ll_box
#undef _ll_obj
#undef _ll_rec
#undef _ll_iter
#undef _ll_delete
|
<
<
<
<
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#ifndef _ll_ffirst
#define _ll_ffirst _cat(first_,_ll_rec)
#endif
#ifndef _ll_flast
#define _ll_flast _cat(last_,_ll_rec)
#endif
#ifndef _ll_fnext
#define _ll_fnext _cat(next_,_ll_rec)
#endif
#define _LL_fn(act) _cat(_cat(_ll_ns,_),_cat(_cat(act,_), _ll_rec))
#ifndef _ll_dropfn
#define _ll_dropfn _LL_fn(drop)
#endif
#ifndef _ll_pushfn
#define _ll_pushfn _LL_fn(push)
#endif
#ifndef _ll_newfn
#define _ll_newfn _LL_fn(new)
#endif
#ifndef _ll_delete
#define _ll_delete free
# ifdef _ll_impl
# include <stdlib.h>
# endif
#endif
#ifdef _ll_impl
# define _LL_impl(...) __VA_ARGS__
# include "def.h"
#else
# define _LL_impl(...) ;
#endif
void _ll_pushfn
(_ll_box* box, _ll_obj* obj) _LL_impl({
if (box -> _ll_flast)
box -> _ll_flast -> _ll_fnext = obj;
else box -> _ll_ffirst = obj;
box -> _ll_flast = obj;
})
_ll_obj* _ll_newfn
(_ll_box* box) _LL_impl({
_ll_obj* o = calloc(1, sizeof(_ll_obj));
_ll_pushfn(box, o);
return o;
})
void _ll_dropfn
(_ll_box* box, _ll_obj* obj) _LL_impl({
if(box -> _ll_ffirst == obj) {
if(box -> _ll_flast == obj) {
box -> _ll_ffirst = box -> _ll_flast = null;
} else {
box -> _ll_ffirst = obj -> _ll_fnext;
}
} else {
................................................................................
}
}
_fatal("BUG in elt deletion routine");
found2 :;
}
}
_ll_delete (obj);
})
#undef _LL_fn
#undef _LL_impl
#undef _ll_pushfn
#undef _ll_newfn
#undef _ll_dropfn
#undef _ll_ffirst
#undef _ll_flast
#undef _ll_ns
#undef _ll_box
#undef _ll_obj
#undef _ll_rec
#undef _ll_iter
#undef _ll_delete
|