Sorry for not being clear enough. The malloc() and free() example has been my way to tell you that you just need to document what users of your lib have to take care. You can't take care of everything where a user of your lib may fail. But you can contract what your lib does and what the user is responsible to do.