diff -urpN conman-0.2.5.orig/util-str.c conman-0.2.5/util-str.c
--- conman-0.2.5.orig/util-str.c 2009-02-13 07:11:56.000000000 +0100
+++ conman-0.2.5/util-str.c 2013-02-20 13:19:12.666727781 +0100
@@ -254,37 +254,31 @@ int substitute_string(char *dst, size_t
char * create_long_time_string(time_t t)
{
- char *p;
+ char buf[160];
struct tm tm;
- const int len = 25; /* YYYY-MM-DD HH:MM:SS ZONE + NUL */
- if (!(p = malloc(len))) {
- out_of_memory();
- }
get_localtime(&t, &tm);
- if (strftime(p, len, "%Y-%m-%d %H:%M:%S %Z", &tm) == 0) {
+ if (strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", &tm) == 0) {
log_err(0, "strftime() failed");
+ buf[0] = '\0';
}
- return(p);
+ return(create_string(buf));
}
char * create_short_time_string(time_t t)
{
- char *p;
+ char buf[80];
struct tm tm;
- const int len = 12; /* MM-DD HH:MM + NUL */
- if (!(p = malloc(len))) {
- out_of_memory();
- }
get_localtime(&t, &tm);
- if (strftime(p, len, "%m-%d %H:%M", &tm) == 0) {
+ if (strftime(buf, sizeof(buf), "%m-%d %H:%M", &tm) == 0) {
log_err(0, "strftime() failed");
+ buf[0] = '\0';
}
- return(p);
+ return(create_string(buf));
}