From b144242a07d8e2f52753af65124fd0ed38e917b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 8 May 2010 09:15:38 +0200 Subject: [PATCH] Fix timestamp handling a little bit --- src/main/worker.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/worker.c b/src/main/worker.c index f1353a2..13d5a69 100644 --- a/src/main/worker.c +++ b/src/main/worker.c @@ -210,11 +210,21 @@ GString *li_worker_current_timestamp(liWorker *wrk, liTimeFunc timefunc, guint f struct tm tm; liWorkerTS *wts; time_t now = (time_t)CUR_TS(wrk); + GArray *a; - if (timefunc == LI_GMTIME) - wts = &g_array_index(wrk->timestamps_gmt, liWorkerTS, format_ndx); - else - wts = &g_array_index(wrk->timestamps_local, liWorkerTS, format_ndx); + if (timefunc == LI_GMTIME) { + a = wrk->timestamps_gmt; + } else { + a = wrk->timestamps_local; + } + + if (format_ndx >= a->len) { + g_array_set_size(a, format_ndx); + } + + wts = &g_array_index(a, liWorkerTS, format_ndx); + + if (!wts->str) wts->str = g_string_sized_new(255); /* cache hit */ if (now == wts->last_generated)