Previous: Replacing Default Memory Manager, Up: Memory Management


2.14.2 Managing Stacks

The stack memory used when evaluating the expression is not used outside the actual expression evaluation. It may well be that the stack storage requirements are not too small to ignore. Even when it is only a few hundreds or a few thousands bytes it may add up something large if, for an instance, hundreds or thousands of parsed expression representations are stored at one time.

Setting the X1f4_E4_MAXSTACK bit in the flags argument of the expression parsing function will cause the expression allocator to not allocate the stacks required for expression evaluating purposes. Instead, it will only compute the storage requirements and set the unsigned records pointed to by the internal_set.s1st and internal_set.s2nd fields in the struct x1f4_attributes_type record argument of the expression parsing function to the maximum of whatever values they had and the computed storage requirements.

See struct x1f4_attributes_type.

The two required stacks must be allocated before the expression evaluation. It is also expected that having them properly aligned for the running system (usually on 4 byte boundaries for 32 bits systems and 8 byte boundaries for 64 bits systems) might avoid a lot of unnecessary grief. malloc does a good in allocating properly aligned buffers most of the times.

The application must allocate the stacks and inform the expression evaluator of their existence. The later task can be perform using one of the x1f4_miss_expression and x1f4_ness_expression functions.

See x1f4_miss_expression.

See x1f4_ness_expression.