16894ec1032b722407ce578d43f47051a62bbc60
4 * LTTng UST trace/channel/event context management.
6 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <lttng/ust-events.h>
25 #include <lttng/ust-tracer.h>
30 int lttng_find_context(struct lttng_ctx
*ctx
, const char *name
)
34 for (i
= 0; i
< ctx
->nr_fields
; i
++) {
35 /* Skip allocated (but non-initialized) contexts */
36 if (!ctx
->fields
[i
].event_field
.name
)
38 if (!strcmp(ctx
->fields
[i
].event_field
.name
, name
))
45 * Note: as we append context information, the pointer location may change.
47 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx_p
)
49 struct lttng_ctx_field
*field
;
50 struct lttng_ctx
*ctx
;
53 *ctx_p
= zmalloc(sizeof(struct lttng_ctx
));
58 if (ctx
->nr_fields
+ 1 > ctx
->allocated_fields
) {
59 struct lttng_ctx_field
*new_fields
;
61 ctx
->allocated_fields
= max_t(size_t, 1, 2 * ctx
->allocated_fields
);
62 new_fields
= zmalloc(ctx
->allocated_fields
* sizeof(struct lttng_ctx_field
));
66 memcpy(new_fields
, ctx
->fields
, sizeof(*ctx
->fields
) * ctx
->nr_fields
);
68 ctx
->fields
= new_fields
;
70 field
= &ctx
->fields
[ctx
->nr_fields
];
76 * Remove last context field.
78 void lttng_remove_context_field(struct lttng_ctx
**ctx_p
,
79 struct lttng_ctx_field
*field
)
81 struct lttng_ctx
*ctx
;
85 assert(&ctx
->fields
[ctx
->nr_fields
] == field
);
86 memset(&ctx
->fields
[ctx
->nr_fields
], 0, sizeof(struct lttng_ctx_field
));
89 void lttng_destroy_context(struct lttng_ctx
*ctx
)
95 for (i
= 0; i
< ctx
->nr_fields
; i
++) {
96 if (ctx
->fields
[i
].destroy
)
97 ctx
->fields
[i
].destroy(&ctx
->fields
[i
]);
This page took 0.032042 seconds and 5 git commands to generate.