added free() for replaced alloca()