+static inline
+void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len,
+ struct lttng_channel *chan, struct lib_ring_buffer_ctx *bufctx)
+{
+ int i;
+ size_t offset = 0;
+
+ if (likely(!ctx)) {
+ *ctx_len = 0;
+ return;
+ }
+ for (i = 0; i < ctx->nr_fields; i++) {
+ if (ctx->fields[i].get_size)
+ offset += ctx->fields[i].get_size(offset);
+ if (ctx->fields[i].get_size_arg)
+ offset += ctx->fields[i].get_size_arg(offset,
+ &ctx->fields[i], bufctx, chan);
+ }
+ *ctx_len = offset;
+}
+