This is particularly useful in modular situations where the allocation
functions are either unknown or private. For instance, in such cases,
the caller of json_dumps() has no way to free the returned buffer.
Since len is known, the copy function does not need to check byte by byte
the end of the string.
Signed-off-by: Olivier Langlois <olivier@olivierlanglois.net>
Thanks to Basile Starynkevitch for the suggestion and initial patch.
Thanks to Jonathan Landis and Deron Meranda for showing how this can
be utilized for implementing secure memory operations.