I was trying to demonstrate how it works on pure C, not C++.
In your example - how should I use the "buffer" ?
result->ErrorBuffer = buffer; ?