4 * Copyright 2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * LTTng trace/channel/event context management.
8 * Dual LGPL v2.1/GPL v2 license.
11 #include <ust/lttng-events.h>
14 #include <ust/usterr-signal-safe.h>
17 * Note: as we append context information, the pointer location may change.
19 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx_p
)
21 struct lttng_ctx_field
*field
;
22 struct lttng_ctx
*ctx
;
25 *ctx_p
= zmalloc(sizeof(struct lttng_ctx
));
30 if (ctx
->nr_fields
+ 1 > ctx
->allocated_fields
) {
31 struct lttng_ctx_field
*new_fields
;
33 ctx
->allocated_fields
= max_t(size_t, 1, 2 * ctx
->allocated_fields
);
34 new_fields
= zmalloc(ctx
->allocated_fields
* sizeof(struct lttng_ctx_field
));
38 memcpy(new_fields
, ctx
->fields
, sizeof(*ctx
->fields
) * ctx
->nr_fields
);
40 ctx
->fields
= new_fields
;
42 field
= &ctx
->fields
[ctx
->nr_fields
];
48 * Remove last context field.
50 void lttng_remove_context_field(struct lttng_ctx
**ctx_p
,
51 struct lttng_ctx_field
*field
)
53 struct lttng_ctx
*ctx
;
57 WARN_ON_ONCE(&ctx
->fields
[ctx
->nr_fields
] != field
);
58 memset(&ctx
->fields
[ctx
->nr_fields
], 0, sizeof(struct lttng_ctx_field
));
61 void lttng_destroy_context(struct lttng_ctx
*ctx
)
67 for (i
= 0; i
< ctx
->nr_fields
; i
++) {
68 if (ctx
->fields
[i
].destroy
)
69 ctx
->fields
[i
].destroy(&ctx
->fields
[i
]);
This page took 0.070846 seconds and 5 git commands to generate.