3 ms·
> The regex engine allocates everything in the arena, including all temporary working memory used while compiling, matching, etc. I do something quite differen
by WalterBright 2y ago
> The regex engine allocates everything in the arena, including all temporary working memory used while compiling, matching, etc.
I do something quite different. I design the API so any data returned by the library function is allocated by the caller. This means the caller has full control over what style of memory management works best.
For example, you can then choose to use stack allocation, RAII, malloc/free, the GC, static allocation, etc.
For a primitive example, snprintf.
- connicpu 2y agoIsn't giving the caller control over the memory exactly what this API does? The caller just passes in a block of memory that will be used for all of the internal allocations as well as the strings returned by the API.
- WalterBright 2y agoIf I misunderstood it, then you are correct.