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
@@ -161,4 +161,5 @@ timer_format_time (double t)
char *str = NULL;
+ size_t size = 0;
if (t < 600)
- asprintf (&str, "%0.3f", t);
+ grecs_asprintf (&str, &size, "%0.3f", t);
else
@@ -176,8 +177,10 @@ timer_format_time (double t)
if (d)
- asprintf (&str, "%ld+%02ld:%02ld:%02ld", d, h, m, s);
+ grecs_asprintf (&str, &size, "%ld+%02ld:%02ld:%02ld", d, h, m, s);
else if (h)
- asprintf (&str, "%02ld:%02ld:%02ld", h, m, s);
+ grecs_asprintf (&str, &size, "%02ld:%02ld:%02ld", h, m, s);
else
- asprintf (&str, "%02ld:%02ld", m, s);
+ grecs_asprintf (&str, &size, "%02ld:%02ld", m, s);
}
+ if (!str)
+ xalloc_die ();
return str;
@@ -205,3 +208,8 @@ _fill_meta (void *sym, void *data)
{ \
- asprintf (&tp->def->kw, "timer:%s:%s", slot->name, #arg); \
+ char *buf = NULL; \
+ size_t size = 0; \
+ grecs_asprintf (&buf, &size, "timer:%s:%s", slot->name, #arg); \
+ if (!buf) \
+ xalloc_die (); \
+ tp->def->kw = buf; \
tp->def->storage = timer_format_time (__cat2__(timer_get_,arg) (slot)); \

Return to:

Send suggestions and report system problems to the System administrator.