Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. node_t * node_init ( nodetype_t type,
  2. char* label,
  3. base_data_type_t base_type,
  4. expression_type_t expression_type,
  5. int n_children,
  6. va_list child_list )
  7. {
  8. //see tree.h for content description
  9. node_t *n = malloc(sizeof(node_t));
  10. n->nodetype = type;
  11. n->label = label;
  12. n->expression_type = expression_type;
  13. n->data_type = base_type;
  14.  
  15. //n->string_index
  16. //TODO figure out this
  17.  
  18. //esential for maneuvering va_args
  19. n->n_children = n_children;
  20.  
  21.  
  22. //create a list of children pointers
  23. node_t* children_list = (node_t *) malloc(sizeof(node_t)*n_children);
  24.  
  25. //fill the child list with the stuff in va_args
  26. for(int i = 0; i < n_children; i++){
  27. *(child_list + i) = va_list(child_list, node_t*);
  28. }
  29.  
  30. //children is a pointer to a pointer so we assign the address of children list.
  31. n->children = &children_list;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement