summaryrefslogtreecommitdiffabout
path: root/src/timer.c
Side-by-side diff
Diffstat (limited to 'src/timer.c') (more/less context) (ignore whitespace changes)
-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 *
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
{
long int s, m, h, d;
@@ -174,12 +175,14 @@ timer_format_time (double t)
s -= m * 60;
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;
}
@@ -203,7 +206,12 @@ _fill_meta (void *sym, void *data)
#define CREATE_DEF(arg) \
if (tp->num) \
{ \
- 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)); \
tp->def->value = tp->def->storage; \
tp->def->expand = NULL; \

Return to:

Send suggestions and report system problems to the System administrator.