It depends - I saw that the C API uses all types of templates for this, for example:
- which require the size of the buffer and buffer to be provided, and return the required size (so that you can adjust the size of the buffer if it has been truncated); many of them allow you to pass
NULLas a buffer if you just ask how big the buffer should be; this allows the caller to use the existing buffer or to assign the appropriate size, albeit with two calls; - separate functions for obtaining the required size and filling the buffer; as above, but with a more intuitive interface;
- which require the size of the buffer and the buffer, but can allocate the buffer themselves, if
NULLpassed as a buffer; maximum flexibility and astringency, but the signature of the function may be confused; - , ; , - , , ; , , , , ;
- , , ; , ; ( ), .
, , - ; , , - , . , , .
, , / , , - ? , ? ? ? , ?
, , , ; , , dll/so, ( free), C runtime . , C - , , .