lib: use type instead of variable for malloc()