zippy / ceptr

(a recomposable medium for distributed social computing) || (semantic self-describing protocol stacks)
http://ceptr.org
GNU General Public License v3.0
88 stars 17 forks source link

generalize tnew is_run_node param to flag #124

Open zippy opened 8 years ago

zippy commented 8 years ago

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.