-struct lttng_ust_ctx_field *lttng_append_context(struct lttng_ust_ctx **ctx_p)
-{
- struct lttng_ust_ctx_field *field;
- int ret;
-
- field = zmalloc(sizeof(struct lttng_ust_ctx_field));
- if (!field)
- goto error_alloc_field;
- field->struct_size = sizeof(struct lttng_ust_ctx_field);
- field->event_field = zmalloc(sizeof(struct lttng_ust_event_field));
- if (!field->event_field)
- goto error_alloc_event_field;
- field->event_field->struct_size = sizeof(struct lttng_ust_event_field);
-
- ret = lttng_add_context(ctx_p);
- if (ret)
- goto error_add_context;
- (*ctx_p)->fields[(*ctx_p)->nr_fields - 1] = field;
- return field;
-
-error_add_context:
- free(field->event_field);
-error_alloc_event_field:
- free(field);
-error_alloc_field:
- return NULL;
-}
-
-/*
- * Takes ownership of @f on success.
- */
-int lttng_context_add_rcu(struct lttng_ust_ctx **ctx_p,
- struct lttng_ust_ctx_field *f)
-{
- struct lttng_ust_ctx *old_ctx = *ctx_p, *new_ctx = NULL;
- struct lttng_ust_ctx_field **new_fields = NULL;
- int ret;
-
- if (old_ctx) {
- new_ctx = zmalloc(sizeof(struct lttng_ust_ctx));
- if (!new_ctx)
- return -ENOMEM;
- new_ctx->struct_size = sizeof(struct lttng_ust_ctx);
- *new_ctx = *old_ctx;
- new_fields = zmalloc(new_ctx->allocated_fields * sizeof(*new_fields));
- if (!new_fields) {
- free(new_ctx);
- return -ENOMEM;
- }
- /* Copy pointers */
- memcpy(new_fields, old_ctx->fields,
- sizeof(*old_ctx->fields) * old_ctx->nr_fields);
- new_ctx->fields = new_fields;
- }
- ret = lttng_add_context(&new_ctx);
- if (ret) {
- free(new_fields);
- free(new_ctx);
- return ret;
- }
- /* Taking ownership of f. */
- (*ctx_p)->fields[(*ctx_p)->nr_fields - 1] = f;
- lttng_context_update(new_ctx);
- lttng_ust_rcu_assign_pointer(*ctx_p, new_ctx);
- lttng_ust_urcu_synchronize_rcu();
- if (old_ctx) {
- free(old_ctx->fields);
- free(old_ctx);
- }
- return 0;
-}
-
-static size_t get_type_max_align(struct lttng_ust_type_common *type)