Re:Efficient string copying and concatenation in C
by Steven_Vellon on Thursday September 12, 2019 @06:36PM
(#20957200)
What I'm getting at, though, is that it's possible to implement it without any copies even if the memory consumption cannot be predetermined. Bypass malloc() and realloc() entirely and invoke brk() to increase the program's segment size. This grows the data segment contiguously (in virtual memory), so there will never be a need to copy the result string to a different buffer. In other words point the result pointer to the start of the heap, and never put anything else on the heap.
[ Parent
| on HN ]
There are no comments on this comment yet.