When the c-capnp compiler runs, currently only takes the len of 1st
segment in the list as a capacity used in the generator for constants
definitions.
This works when the schema processing only generates 1 segment, or the
1st segment has 8192 bytes. There are cases where the fd returns
multiple segments an the first one has very low capacity (e.g. 96 or 80).
Hence, if more constants require to be allocated for the current schema
it will have misleading positions.
This commit takes a conservative approach by summing up all the lenghts
of capnproto segments obtained at the fd_init call of the compiler.
Those values are taken to set the memory allocation and the max
capacity for the segment utilized in the code generation.
When the c-capnp compiler runs, currently only takes the len of 1st segment in the list as a capacity used in the generator for constants definitions.
This works when the schema processing only generates 1 segment, or the 1st segment has 8192 bytes. There are cases where the fd returns multiple segments an the first one has very low capacity (e.g. 96 or 80). Hence, if more constants require to be allocated for the current schema it will have misleading positions.
This commit takes a conservative approach by summing up all the lenghts of capnproto segments obtained at the fd_init call of the compiler. Those values are taken to set the memory allocation and the max capacity for the segment utilized in the code generation.