Reentrant library

A reentrant library is a library which does not abort on normal user input.

We are using a lot of asserts. Asserts should be used only in places where we are certain that they will never be called in order to be able to debug better.

We should return for example EINVAL instead of doing an assert(0) on bad user input.

Furthermore there are a lot of aborts. Some of them will never happen, but others are done when it should actually return a ENOMEM error.
Remove the trailing ';'