/* It's possible the control URIs array contains more than one URI */
memcpy(tmp_uris, ctrl_uris, sizeof(struct lttng_uri) * size_ctrl);
++idx;
+ free(ctrl_uris);
}
if (data_uris) {
memcpy(&tmp_uris[idx], data_uris, sizeof(struct lttng_uri));
+ free(data_uris);
}
*uris = tmp_uris;
*/
int lttng_create_session(const char *name, const char *url)
{
+ int ret;
ssize_t size;
struct lttcomm_session_msg lsm;
struct lttng_uri *uris = NULL;
lsm.u.uri.size = size;
- return ask_sessiond_varlen(&lsm, uris, sizeof(struct lttng_uri) * size,
+ ret = ask_sessiond_varlen(&lsm, uris, sizeof(struct lttng_uri) * size,
NULL);
+
+ free(uris);
+ return ret;
}
/*
int lttng_set_consumer_url(struct lttng_handle *handle,
const char *control_url, const char *data_url)
{
+ int ret;
ssize_t size;
struct lttcomm_session_msg lsm;
struct lttng_uri *uris = NULL;
lsm.u.uri.size = size;
- return ask_sessiond_varlen(&lsm, uris, sizeof(struct lttng_uri) * size,
+ ret = ask_sessiond_varlen(&lsm, uris, sizeof(struct lttng_uri) * size,
NULL);
+
+ free(uris);
+ return ret;
}
/*
int _lttng_create_session_ext(const char *name, const char *url,
const char *datetime)
{
+ int ret;
ssize_t size;
struct lttcomm_session_msg lsm;
struct lttng_uri *uris = NULL;
/* There should never be a data URL */
size = parse_str_urls_to_uri(url, NULL, &uris);
if (size < 0) {
- return -LTTNG_ERR_INVALID;
+ ret = -LTTNG_ERR_INVALID;
+ goto error;
}
lsm.u.uri.size = size;
if (size > 0 && uris[0].dtype != LTTNG_DST_PATH && strlen(uris[0].subdir) == 0) {
- int ret;
-
ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s-%s", name,
datetime);
if (ret < 0) {
PERROR("snprintf uri subdir");
- return -LTTNG_ERR_FATAL;
+ ret = -LTTNG_ERR_FATAL;
+ goto error;
}
}
- return ask_sessiond_varlen(&lsm, uris, sizeof(struct lttng_uri) * size,
+ ret = ask_sessiond_varlen(&lsm, uris, sizeof(struct lttng_uri) * size,
NULL);
+
+error:
+ free(uris);
+ return ret;
}
/*