zippy/ceptr

generalize tnew is_run_node param to flag

Opened this issue · 0 comments

zippy commented

we want to be able to add other allocation instructions, like appending a null byte, which would be easier if there were allocation flags. (see the @todo hack in process.c STREAM_READ.

currently there is one boolean parameter to various low-level tree node allocation routines to select whether to allocate the node as a run-tree or not (this allocates more memory for each node, memory used to hold the state when reducing the trees), which is not necessary when the trees aren't being reduced.
At line 963 of src/process.c there's a call to __t_new in which we'd like to be able add a trailing null byte to the surface of the tree node when it's allocated (in that particular place we end up not having to because the source buffer has some extra bytes that we can pop the NULL into and just increase the length by a byte, but in general that wouldn't be available, and it's a bad idea to be changing the incoming buffer!). So, the solution is to make the boolean is_run_node in __t_new into a more general "int alloc_flags" param into which you pass bit defined flags something like TNEW_IS_RUN_NODE and TNEW_ADD_NULL and later other things too if needed.