From 37f1c23617e54ba79c11ff6dc4c4ce7ad07f7be9 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 21 Jan 2013 15:49:45 -0500 Subject: [PATCH] Add an allocation function for ust stream Signed-off-by: David Goulet --- src/bin/lttng-sessiond/ust-app.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 397a2dfab..f6f2c64ae 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -378,6 +378,28 @@ error: return NULL; } +/* + * Allocate and initialize a UST app stream. + * + * Return newly allocated stream pointer or NULL on error. + */ +static struct ust_app_stream *alloc_ust_app_stream(void) +{ + struct ust_app_stream *stream = NULL; + + stream = zmalloc(sizeof(*stream)); + if (stream == NULL) { + PERROR("zmalloc ust app stream"); + goto error; + } + + /* Zero could be a valid value for a handle so flag it to -1. */ + stream->handle = -1; + +error: + return stream; +} + /* * Alloc new UST app event. */ @@ -2362,9 +2384,8 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) /* Create all streams */ while (1) { /* Create UST stream */ - ustream = zmalloc(sizeof(*ustream)); + ustream = alloc_ust_app_stream(); if (ustream == NULL) { - PERROR("zmalloc ust stream"); goto error_rcu_unlock; } -- 2.34.1