summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-08 15:38:27 +0200
committerLennart Poettering <lennart@poettering.net>2013-04-08 15:48:31 +0200
commita569398925430de1f8479262e8ab39502054f2e9 (patch)
tree6edeb32b9b6f2f3feeaacf7b95d46359fd60791a /src/journal
parentc2457105d76e3daf159f554a9bafb9751b23d756 (diff)
journald: get rid of one more memory allocation
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journald-server.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 2ae5624a04..74482f184d 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -537,9 +537,10 @@ static void dispatch_message_real(
char pid[sizeof("_PID=") + DECIMAL_STR_MAX(ucred->pid)],
uid[sizeof("_UID=") + DECIMAL_STR_MAX(ucred->uid)],
- gid[sizeof("_GID=") + DECIMAL_STR_MAX(ucred->gid)];
+ gid[sizeof("_GID=") + DECIMAL_STR_MAX(ucred->gid)],
+ source_time[sizeof("_SOURCE_REALTIME_TIMESTAMP=" + DECIMAL_STR_MAX(usec_t))];
- char _cleanup_free_ *source_time = NULL, *boot_id = NULL, *machine_id = NULL,
+ char _cleanup_free_ *boot_id = NULL, *machine_id = NULL,
*comm = NULL, *cmdline = NULL, *hostname = NULL,
*audit_session = NULL, *audit_loginuid = NULL,
*exe = NULL, *cgroup = NULL, *session = NULL,
@@ -678,9 +679,10 @@ static void dispatch_message_real(
}
if (tv) {
- if (asprintf(&source_time, "_SOURCE_REALTIME_TIMESTAMP=%llu",
- (unsigned long long) timeval_load(tv)) >= 0)
- IOVEC_SET_STRING(iovec[n++], source_time);
+ snprintf(source_time, sizeof(source_time) - 1, "_SOURCE_REALTIME_TIMESTAMP=%llu",
+ (unsigned long long) timeval_load(tv));
+ char_array_0(source_time);
+ IOVEC_SET_STRING(iovec[n++], source_time);
}
/* Note that strictly speaking storing the boot id here is