aboutsummaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/timer.c b/src/timer.c
index 71f63f9..1634462 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -159,8 +159,9 @@ char *
159timer_format_time (double t) 159timer_format_time (double t)
160{ 160{
161 char *str = NULL; 161 char *str = NULL;
162 size_t size = 0;
162 if (t < 600) 163 if (t < 600)
163 asprintf (&str, "%0.3f", t); 164 grecs_asprintf (&str, &size, "%0.3f", t);
164 else 165 else
165 { 166 {
166 long int s, m, h, d; 167 long int s, m, h, d;
@@ -174,12 +175,14 @@ timer_format_time (double t)
174 s -= m * 60; 175 s -= m * 60;
175 176
176 if (d) 177 if (d)
177 asprintf (&str, "%ld+%02ld:%02ld:%02ld", d, h, m, s); 178 grecs_asprintf (&str, &size, "%ld+%02ld:%02ld:%02ld", d, h, m, s);
178 else if (h) 179 else if (h)
179 asprintf (&str, "%02ld:%02ld:%02ld", h, m, s); 180 grecs_asprintf (&str, &size, "%02ld:%02ld:%02ld", h, m, s);
180 else 181 else
181 asprintf (&str, "%02ld:%02ld", m, s); 182 grecs_asprintf (&str, &size, "%02ld:%02ld", m, s);
182 } 183 }
184 if (!str)
185 xalloc_die ();
183 return str; 186 return str;
184} 187}
185 188
@@ -203,7 +206,12 @@ _fill_meta (void *sym, void *data)
203#define CREATE_DEF(arg) \ 206#define CREATE_DEF(arg) \
204 if (tp->num) \ 207 if (tp->num) \
205 { \ 208 { \
206 asprintf (&tp->def->kw, "timer:%s:%s", slot->name, #arg); \ 209 char *buf = NULL; \
210 size_t size = 0; \
211 grecs_asprintf (&buf, &size, "timer:%s:%s", slot->name, #arg); \
212 if (!buf) \
213 xalloc_die (); \
214 tp->def->kw = buf; \
207 tp->def->storage = timer_format_time (__cat2__(timer_get_,arg) (slot)); \ 215 tp->def->storage = timer_format_time (__cat2__(timer_get_,arg) (slot)); \
208 tp->def->value = tp->def->storage; \ 216 tp->def->value = tp->def->storage; \
209 tp->def->expand = NULL; \ 217 tp->def->expand = NULL; \

Return to:

Send suggestions and report system problems to the System administrator.