int number_of_members(struct_table *curr) { int n; symbol_table * i = curr -> s; //Extract the symbol table /* Count the symbols and then call my children to do the same */ call_recursive(i, 1); n = struct_size; //Copying the global size to local size and then zeroing the global one. struct_size = 0; return n; }
void call_recursive (symbol_table *t, int depth ) { symbol *curr = NULL; int i,j; if (t == NULL) return; curr = t->s; while (curr != NULL) { struct_size += 1; /* print any symbol tables that are subordinate to this symbol */ for(j = 0; j < t -> num_children; j++) if (t->children[j]->assoc == curr) call_recursive(t->children[j], depth+1); curr = curr->up; } for (i = 0; i < t->num_children; i++) if (t -> children[i] -> assoc == NULL) call_recursive(t -> children[i], depth + 1); }
int call_recursive2(void) { return call_recursive(); }