+/* Dynamically allocate memory for a class data structure,
+ or cdat, after a class has been identified in a grammar.
+ We also create a stack of class pointers so that
+ we can access the cdat during processing of that
+ cdats sets and elements, a requirement because the
+ nature of recursive classes prevents us from accessing
+ the cdat based on the previous index into cdat_buf,
+ which is a list of all allocated cdats*/
+void
+push_cdat(char* name)
+{
+
+ malloc_cdat();
+
+ memmove(cdat_buf[num_cdats]->name, name, 32);
+ cdat_buf[num_cdats]->idx = num_cdats;
+
+ /* Set the cdat as a class of the previous cdat */
+ (*cdat_stackp)->class_list[(*cdat_stackp)->num_classes++] = cdat_buf[num_cdats];
+
+ /* Push the cdat onto the cdat_stack */
+ *++cdat_stackp = cdat_buf[num_cdats++];
+
+}
+
+void
+pop_cdat()
+{
+ *cdat_stackp = NULL;
+ cdat_stackp--;
+}
+
+void
+inc_odat()
+{
+ num_odats++;
+ if(num_odats >= curr_max_odats)
+ {
+ if( (realloc((void*) odat_buf, PTRS_IN_PAGE * 4)) == NULL)
+ perror("realloc odat_buf failed");
+ curr_max_odats += PTRS_IN_PAGE;
+ }
+ if( (CURR_ODAT = (struct odat*) malloc(sizeof (struct odat))) == NULL)
+ {
+ perror("malloc odat failed");
+ }
+
+}
+
+void
+inc_vdat()
+{
+ num_vdats++;
+ if(num_vdats >= curr_max_vdats)
+ {
+ if( (realloc((void*) vdat_buf, PTRS_IN_PAGE * 4)) == NULL)
+ perror("realloc vdat_buf failed");
+ curr_max_vdats += PTRS_IN_PAGE;
+ }
+ if((CURR_VDAT = (struct vdat*) malloc(sizeof (struct vdat))) == NULL)
+ {
+ perror("malloc vdat failed");
+ }
+
+}
+
+void
+inc_link()
+{
+ num_links++;
+ if(num_links >= curr_max_links)
+ {
+ if( (realloc((void*) link_buf, PTRS_IN_PAGE * 4)) == NULL)
+ perror("realloc vdat_buf failed");
+ curr_max_links += PTRS_IN_PAGE;
+ }
+ if((CURR_LINK = (struct link*) malloc(sizeof (struct link))) == NULL)
+ {
+ perror("malloc link failed");
+ }
+}
+
+void
+inc_ref()
+{
+
+ if(num_refs % 16 == 0)
+ {
+ posts[num_posts++] = *CURR_REF;
+ }
+
+ num_refs++;
+ if(num_refs >= curr_max_refs)
+ {
+ if( (realloc((void*) ref_buf, PTRS_IN_PAGE * 4)) == NULL)
+ perror("realloc ref_buf failed");
+ curr_max_refs += PTRS_IN_PAGE;
+ }
+ if((CURR_REF = (struct ref*) malloc(sizeof (struct ref))) == NULL)
+ perror("malloc ref failed");
+}