Use correct way to free pointers when wrapping structs