958910d19ce40716f4ba28198ad08f8462b1137a
37 #define CURR_CDAT (*cdat_stackp)
38 #define CURR_SET set_list[CURR_CDAT->num_sets]
39 #define CURR_ELE ele_list[CURR_CDAT->CURR_SET.num_ele]
40 #define PREV_REF (ref_buf[num_refs-1])
41 #define CURR_REF (ref_buf[num_refs])
42 #define PREV_ODAT (odat_buf[num_odats-1])
43 #define CURR_ODAT (odat_buf[num_odats])
44 #define CURR_VDAT (vdat_buf[num_vdats])
45 #define PREV_VDAT (vdat_buf[num_vdats-1])
46 #define CURR_MODEL (CURR_VDAT->model_list[CURR_VDAT->num_models])
47 #define CURR_LINK (link_buf[num_links])
48 #define CURR_POST (post_buf[num_posts])
49 #define CURR_QUAD (CURR_ODAT->quad_file)
53 int curr_max_cdats
= PTRS_IN_PAGE
;
55 struct cdat
* cdat_buf
[PTRS_IN_PAGE
];
56 struct cdat
* cdat_stack
[PTRS_IN_PAGE
];
57 struct cdat
** cdat_stackp
;
61 int curr_max_odats
= PTRS_IN_PAGE
;
62 struct odat
* odat_buf
[PTRS_IN_PAGE
];
66 int curr_max_vdats
= PTRS_IN_PAGE
;
67 struct vdat
* vdat_buf
[PTRS_IN_PAGE
];
71 int curr_max_refs
= PTRS_IN_PAGE
;
72 struct ref
* ref_buf
[PTRS_IN_PAGE
];
73 uint64_t ss_ref_id
= 0x00FFFFFF; /* system space for ref_ids */
76 int curr_max_posts
= PTRS_IN_PAGE
;
77 struct ref
* post_buf
[PTRS_IN_PAGE
];
81 int curr_max_links
= PTRS_IN_PAGE
;
82 struct link
* link_buf
[PTRS_IN_PAGE
];
85 /* The initalization function of the IR. */
90 /* Init root cdat and stack */
91 char root
[4] = "root";
93 if( (cdat_buf
[num_cdats
] = (struct cdat
*) malloc(sizeof(struct cdat
))) == NULL
)
95 perror("malloc root class failed\n");
98 cdat_buf
[num_cdats
]->idx
= num_cdats
;
99 memmove(cdat_buf
[num_cdats
]->name
, root
, 4);
101 cdat_stackp
= cdat_stack
;
102 *cdat_stackp
++ = cdat_buf
[num_cdats
++];
113 for(i
= 0; i
<= num_odats
; i
++)
117 for(i
= 0; i
<= num_cdats
; i
++)
121 for(i
= 0; i
<= num_vdats
; i
++)
125 for(i
= 0; i
<= num_refs
; i
++)
129 for(i
= 0; i
<= num_links
; i
++)
141 if(curr_max_cdats
<= num_cdats
)
142 { if( (realloc((void*) cdat_buf
, PTRS_IN_PAGE
* 4)) == NULL
)
143 perror("realloc cdat_buf failed");
144 curr_max_cdats
+= PTRS_IN_PAGE
;
145 if( (realloc( (void*) cdat_stack
, PTRS_IN_PAGE
* 4)) == NULL
) //increase cdat_stack also
146 perror("realloc cdat_stack failed");
148 if( (CURR_CDAT
= (struct cdat
*) malloc(sizeof (struct cdat
)) ) == NULL
)
149 perror("malloc cdat failed");
160 if(num_odats
>= curr_max_odats
)
161 { if( (realloc((void*) odat_buf
, PTRS_IN_PAGE
* 4)) == NULL
)
162 perror("realloc odat_buf failed");
163 curr_max_odats
+= PTRS_IN_PAGE
;
165 if( (CURR_ODAT
= (struct odat
*) malloc(sizeof (struct odat
))) == NULL
)
166 perror("malloc odat failed");
176 if(num_vdats
>= curr_max_vdats
)
177 { if( (realloc((void*) vdat_buf
, PTRS_IN_PAGE
* 4)) == NULL
)
178 perror("realloc vdat_buf failed");
179 curr_max_vdats
+= PTRS_IN_PAGE
;
181 if((CURR_VDAT
= (struct vdat
*) malloc(sizeof (struct vdat
))) == NULL
)
182 perror("malloc vdat failed");
192 if(num_links
>= curr_max_links
)
193 { if( (realloc((void*) link_buf
, PTRS_IN_PAGE
* 4)) == NULL
)
194 perror("realloc vdat_buf failed");
195 curr_max_links
+= PTRS_IN_PAGE
;
197 if((CURR_LINK
= (struct link
*) malloc(sizeof (struct link
))) == NULL
)
198 perror("malloc link failed");
209 if(num_refs
% 16 == 0)
210 { CURR_POST
= CURR_REF
;
214 if(num_refs
>= curr_max_refs
)
215 { if( (realloc((void*) ref_buf
, PTRS_IN_PAGE
* 4)) == NULL
)
216 perror("realloc ref_buf failed");
217 curr_max_refs
+= PTRS_IN_PAGE
;
219 if((CURR_REF
= (struct ref
*) malloc(sizeof (struct ref
))) == NULL
)
220 perror("malloc ref failed");
228 if(num_posts
>= curr_max_posts
)
229 { if( (realloc((void*) ref_buf
, PTRS_IN_PAGE
* 4)) == NULL
)
230 perror("realoc post_buf failed");
231 curr_max_posts
+= PTRS_IN_PAGE
;
233 if ((CURR_POST
= (struct ref
*) malloc (sizeof (struct ref
))) == NULL
)
234 perror("malloc post failed");
261 return &CURR_CDAT
->CURR_SET
;
267 return &CURR_CDAT
->CURR_SET
.CURR_ELE
;