]>
Commit | Line | Data |
---|---|---|
e2527cba P |
1 | #include <stdlib.h> |
2 | #include <assert.h> | |
3 | #include "../core/nsmalloc.h" | |
4 | #include "trusts.h" | |
5 | ||
6 | #define ALLOCUNIT 100 | |
7 | ||
8 | trustgroup_t *trustgroup_freelist; | |
9 | trustgroupidentcount_t *trustgroupidentcount_freelist; | |
10 | trusthost_t *trusthost_freelist; | |
11 | trustblock_t *trustblock_freelist; | |
12 | ||
13 | trustgroup_t *newtrustgroup() { | |
14 | trustgroup_t *trustgroup; | |
15 | int i; | |
16 | ||
17 | if( trustgroup_freelist ==NULL ) { | |
18 | trustgroup_freelist=(trustgroup_t *)nsmalloc(POOL_TRUSTS,ALLOCUNIT*sizeof(trustgroup_t)); | |
19 | ||
20 | for (i=0;i<(ALLOCUNIT-1);i++) { | |
21 | trustgroup_freelist[i].nextbyid=(trustgroup_t *)&(trustgroup_freelist[i+1]); | |
22 | } | |
23 | trustgroup_freelist[ALLOCUNIT-1].nextbyid=NULL; | |
24 | } | |
25 | ||
26 | trustgroup=trustgroup_freelist; | |
27 | trustgroup_freelist=(trustgroup_t *)trustgroup->nextbyid; | |
28 | ||
29 | return trustgroup; | |
30 | } | |
31 | ||
32 | void freetrustgroup (trustgroup_t *trustgroup) { | |
33 | trustgroup->nextbyid=(trustgroup_t *)trustgroup_freelist; | |
34 | trustgroup_freelist=trustgroup; | |
35 | } | |
36 | ||
37 | trusthost_t *newtrusthost() { | |
38 | trusthost_t *trusthost; | |
39 | int i; | |
40 | ||
41 | if( trusthost_freelist ==NULL ) { | |
42 | trusthost_freelist=(trusthost_t *)nsmalloc(POOL_TRUSTS,ALLOCUNIT*sizeof(trusthost_t)); | |
43 | ||
44 | for (i=0;i<(ALLOCUNIT-1);i++) { | |
45 | trusthost_freelist[i].nextbyid=(trusthost_t *)&(trusthost_freelist[i+1]); | |
46 | } | |
47 | trusthost_freelist[ALLOCUNIT-1].nextbyid=NULL; | |
48 | } | |
49 | ||
50 | trusthost=trusthost_freelist; | |
51 | trusthost_freelist=(trusthost_t *)trusthost->nextbyid; | |
52 | ||
53 | return trusthost; | |
54 | } | |
55 | ||
56 | void freetrusthost (trusthost_t *trusthost) { | |
57 | trusthost->nextbyid=(trusthost_t *)trusthost_freelist; | |
58 | trusthost_freelist=trusthost; | |
59 | } | |
60 | ||
61 | ||
62 | trustgroupidentcount_t *newtrustgroupidentcount() { | |
63 | trustgroupidentcount_t *trustgroupidentcount; | |
64 | int i; | |
65 | ||
66 | if( trustgroupidentcount_freelist ==NULL ) { | |
67 | trustgroupidentcount_freelist=(trustgroupidentcount_t *)nsmalloc(POOL_TRUSTS,ALLOCUNIT*sizeof(trustgroupidentcount_t)); | |
68 | ||
69 | for (i=0;i<(ALLOCUNIT-1);i++) { | |
70 | trustgroupidentcount_freelist[i].next=(trustgroupidentcount_t *)&(trustgroupidentcount_freelist[i+1]); | |
71 | } | |
72 | trustgroupidentcount_freelist[ALLOCUNIT-1].next=NULL; | |
73 | } | |
74 | ||
75 | trustgroupidentcount=trustgroupidentcount_freelist; | |
76 | trustgroupidentcount_freelist=(trustgroupidentcount_t *)trustgroupidentcount->next; | |
77 | ||
78 | return trustgroupidentcount; | |
79 | } | |
80 | ||
81 | void freetrustgroupidentcount (trustgroupidentcount_t *trustgroupidentcount) { | |
82 | trustgroupidentcount->next=(trustgroupidentcount_t *)trustgroupidentcount_freelist; | |
83 | trustgroupidentcount_freelist=trustgroupidentcount; | |
84 | } | |
85 | ||
86 | trustblock_t *newtrustblock() { | |
87 | trustblock_t *trustblock; | |
88 | int i; | |
89 | ||
90 | if( trustblock_freelist ==NULL ) { | |
91 | trustblock_freelist=(trustblock_t *)nsmalloc(POOL_TRUSTS,ALLOCUNIT*sizeof(trustblock_t)); | |
92 | ||
93 | for (i=0;i<(ALLOCUNIT-1);i++) { | |
94 | trustblock_freelist[i].next=(trustblock_t *)&(trustblock_freelist[i+1]); | |
95 | } | |
96 | trustblock_freelist[ALLOCUNIT-1].next=NULL; | |
97 | } | |
98 | ||
99 | trustblock=trustblock_freelist; | |
100 | trustblock_freelist=(trustblock_t *)trustblock->next; | |
101 | ||
102 | return trustblock; | |
103 | } | |
104 | ||
105 | void freetrustblock (trustblock_t *trustblock) { | |
106 | trustblock->next=(trustblock_t *)trustblock_freelist; | |
107 | trustblock_freelist=trustblock; | |
108 | } | |
109 |