4 * Copyright 2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * LTTng UST trace/channel/event context management.
8 * Dual LGPL v2.1/GPL v2 license.
11 #include <lttng/ust-events.h>
12 #include <lttng/ust-tracer.h>
17 int lttng_find_context(struct lttng_ctx
*ctx
, const char *name
)
21 for (i
= 0; i
< ctx
->nr_fields
; i
++) {
22 /* Skip allocated (but non-initialized) contexts */
23 if (!ctx
->fields
[i
].event_field
.name
)
25 if (!strcmp(ctx
->fields
[i
].event_field
.name
, name
))
32 * Note: as we append context information, the pointer location may change.
34 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx_p
)
36 struct lttng_ctx_field
*field
;
37 struct lttng_ctx
*ctx
;
40 *ctx_p
= zmalloc(sizeof(struct lttng_ctx
));
45 if (ctx
->nr_fields
+ 1 > ctx
->allocated_fields
) {
46 struct lttng_ctx_field
*new_fields
;
48 ctx
->allocated_fields
= max_t(size_t, 1, 2 * ctx
->allocated_fields
);
49 new_fields
= zmalloc(ctx
->allocated_fields
* sizeof(struct lttng_ctx_field
));
53 memcpy(new_fields
, ctx
->fields
, sizeof(*ctx
->fields
) * ctx
->nr_fields
);
55 ctx
->fields
= new_fields
;
57 field
= &ctx
->fields
[ctx
->nr_fields
];
63 * Remove last context field.
65 void lttng_remove_context_field(struct lttng_ctx
**ctx_p
,
66 struct lttng_ctx_field
*field
)
68 struct lttng_ctx
*ctx
;
72 assert(&ctx
->fields
[ctx
->nr_fields
] == field
);
73 memset(&ctx
->fields
[ctx
->nr_fields
], 0, sizeof(struct lttng_ctx_field
));
76 void lttng_destroy_context(struct lttng_ctx
*ctx
)
82 for (i
= 0; i
< ctx
->nr_fields
; i
++) {
83 if (ctx
->fields
[i
].destroy
)
84 ctx
->fields
[i
].destroy(&ctx
->fields
[i
]);
This page took 0.035218 seconds and 4 git commands to generate.