Wouldn't the allocated memory be freed automatically when the function returns?