Replace PATH_MAX with dynamic memory allocation