lib: move kasprintf to a separate file