- /*
- * For application context, add it by expanding
- * ctx array.
- */
- memset(&new_field, 0, sizeof(new_field));
- new_field.field_name = strdup(name);
- if (!new_field.field_name)
- return -ENOMEM;
- new_field.event_field.name = new_field.field_name;
- new_field.event_field.type.atype = atype_dynamic;
+ new_field = zmalloc(sizeof(struct lttng_ust_ctx_field));
+ if (!new_field) {
+ ret = -ENOMEM;
+ goto error_field_alloc;
+ }
+ new_field->struct_size = sizeof(struct lttng_ust_ctx_field);
+ new_field->event_field = zmalloc(sizeof(struct lttng_ust_event_field));
+ if (!new_field->event_field) {
+ ret = -ENOMEM;
+ goto error_event_field_alloc;
+ }
+ new_field->field_name = strdup(name);
+ if (!new_field->field_name) {
+ ret = -ENOMEM;
+ goto error_field_name_alloc;
+ }
+ new_field->event_field->name = new_field->field_name;
+ new_field->event_field->type.atype = atype_dynamic;