Avoid using malloc in scope guard logger.

Use a temporary object with its own buffer, which lives on the stack.

Reformat SCOPE_INFO_FMT to not be all on one line.
Other minor reformatting.
This commit is contained in:
Jonathan G Rennison
2016-02-25 00:20:31 +00:00
parent ae6e43c5fa
commit 0062881a46
4 changed files with 45 additions and 25 deletions

View File

@@ -852,7 +852,7 @@ static void RunVehicleDayProc()
/* Run the day_proc for every DAY_TICKS vehicle starting at _date_fract. */
Vehicle *v = NULL;
SCOPE_INFO_FMT([&v], "RunVehicleDayProc: %s", DumpVehicleInfo(v));
SCOPE_INFO_FMT([&v], "RunVehicleDayProc: %s", scope_dumper().VehicleInfo(v));
for (size_t i = _date_fract; i < Vehicle::GetPoolSize(); i += DAY_TICKS) {
v = Vehicle::Get(i);
if (v == NULL) continue;
@@ -888,7 +888,7 @@ void CallVehicleTicks()
FOR_ALL_STATIONS(st) LoadUnloadStation(st);
Vehicle *v = NULL;
SCOPE_INFO_FMT([&v], "CallVehicleTicks: %s", DumpVehicleInfo(v));
SCOPE_INFO_FMT([&v], "CallVehicleTicks: %s", scope_dumper().VehicleInfo(v));
FOR_ALL_VEHICLES(v) {
/* Vehicle could be deleted in this tick */
if (!v->Tick()) {