actions: introduce lttng_action_init
[lttng-tools.git] / src / common / actions / notify.c
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #include <lttng/action/action-internal.h>
9 #include <lttng/action/notify-internal.h>
10 #include <common/macros.h>
11 #include <assert.h>
12
13 static
14 void lttng_action_notify_destroy(struct lttng_action *action)
15 {
16 free(action);
17 }
18
19 static
20 int lttng_action_notify_serialize(struct lttng_action *action,
21 struct lttng_dynamic_buffer *buf)
22 {
23 return 0;
24 }
25
26 struct lttng_action *lttng_action_notify_create(void)
27 {
28 struct lttng_action_notify *notify;
29
30 notify = zmalloc(sizeof(struct lttng_action_notify));
31 if (!notify) {
32 goto end;
33 }
34
35 lttng_action_init(&notify->parent, LTTNG_ACTION_TYPE_NOTIFY, NULL,
36 lttng_action_notify_serialize,
37 lttng_action_notify_destroy);
38 end:
39 return &notify->parent;
40 }
41
42 ssize_t lttng_action_notify_create_from_buffer(
43 const struct lttng_buffer_view *view,
44 struct lttng_action **action)
45 {
46 ssize_t consumed_length;
47
48 *action = lttng_action_notify_create();
49 if (!*action) {
50 consumed_length = -1;
51 goto end;
52 }
53
54 consumed_length = 0;
55 end:
56 return consumed_length;
57 }
This page took 0.040357 seconds and 4 git commands to generate.