Name: Anonymous 2011-11-23 22:39
How to properly release heap-based symbols in a POSIX-compliant parser generated by Yacc? Standard Yacc does not support the convenient
The only possible alternatives I see in this behalf are:
- Avoid heap allocation and use static allocation; (easy but bad)
- Provide some means to save every allocated pointer during grammar traversal in some context and release the pointers appropriately afterwards; (boring to implement, bloats the code, not worth the hassle)
- Use some pool allocator. (Inconvenient and yield pointers without free()-semantics)
Suggestions are appreciated.
%destructor directive present in modern versions of GNU Bison.The only possible alternatives I see in this behalf are:
- Avoid heap allocation and use static allocation; (easy but bad)
- Provide some means to save every allocated pointer during grammar traversal in some context and release the pointers appropriately afterwards; (boring to implement, bloats the code, not worth the hassle)
- Use some pool allocator. (Inconvenient and yield pointers without free()-semantics)
Suggestions are appreciated.