I don't get it. That's it.
Help me understand
"Encoding Base58
---------------
Allocate a string to store the base58 content, create a size_t variable with the
size of that allocation, and call:
bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz)
Note that you must pass a pointer to the string size variable, not the size
itself. When b58enc returns, the variable will be modified to contain the actual
number of bytes used (including the null terminator). If encoding fails for any
reason, or if the string buffer is not large enough for the result, b58enc will
return false. Otherwise, it returns true to indicate success."
It's good old fashioned C 'optimized' API. If you have a buffer already allocated of size_t, you can try to use it.
However, it's too short --> you get false. And you need to try with a bigger buffer.
If it's ok, it returns the effective size that was used. The string is null terminated but by giving you the size back, you avoid a strlen which scans the string.
Believe me or not, but these kinds of cubblesome API used to be the norm when memory was precious.