I don't see freeBuffer() in the wrapper file, needs to be added.  You'll want to be careful not to double-free.