lib.[ch]: Move the memory allocation out-of-line.