From: David Goulet Date: Mon, 21 Jan 2013 20:49:45 +0000 (-0500) Subject: Add an allocation function for ust stream X-Git-Tag: v2.2.0-rc1~100 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=37f1c23617e54ba79c11ff6dc4c4ce7ad07f7be9;hp=030a66fa43d2f6666afa9e4a90ca755eb5670555 Add an allocation function for ust stream Signed-off-by: David Goulet --- 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; }