aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
blob: 162256828792b73331713586a255cc1b98842e8c (plain)
  1. #include <stdbool.h>
  2. #include <stdio.h>
  3. #include "buffer.h"
  4. #include "ast.h"
  5. #include "inlines.h"
  6. #include "references.h"
  7. // Free a node_block list and any children.
  8. void cmark_free_nodes(node_block *e)
  9. {
  10. node_block * next;
  11. while (e != NULL) {
  12. free_inlines(e->inline_content);
  13. strbuf_free(&e->string_content);
  14. if (e->tag == BLOCK_FENCED_CODE) {
  15. strbuf_free(&e->as.code.info);
  16. } else if (e->tag == BLOCK_DOCUMENT) {
  17. reference_map_free(e->as.document.refmap);
  18. }
  19. if (e->last_child) {
  20. // Splice children into list
  21. e->last_child->next = e->next;
  22. e->next = e->children;
  23. }
  24. next = e->next;
  25. free(e);
  26. e = next;
  27. }
  28. }