bool internal_event,
struct ltt_ust_event **ust_event)
{
- struct ltt_ust_event *local_ust_event;
enum lttng_error_code ret = LTTNG_OK;
+ std::unique_ptr<ltt_ust_event> local_ust_event;
LTTNG_ASSERT(ev);
goto error;
}
- local_ust_event = zmalloc<ltt_ust_event>();
- if (local_ust_event == nullptr) {
- PERROR("ust event zmalloc");
+ try {
+ local_ust_event = lttng::make_unique<ltt_ust_event>();
+ } catch (const std::bad_alloc &ex) {
+ ERR_FMT("Failed to allocate ltt_ust_event");
ret = LTTNG_ERR_NOMEM;
goto error;
}
default:
ERR("Unknown ust instrumentation type (%d)", ev->type);
ret = LTTNG_ERR_INVALID;
- goto error_free_event;
+ goto error;
}
/* Copy event name */
default:
ERR("Unknown ust loglevel type (%d)", ev->loglevel_type);
ret = LTTNG_ERR_INVALID;
- goto error_free_event;
+ goto error;
}
/* Same layout. */
local_ust_event->attr.loglevel_type,
local_ust_event->attr.loglevel);
- *ust_event = local_ust_event;
+ *ust_event = local_ust_event.release();
return ret;
-error_free_event:
- free(local_ust_event);
error:
free(filter_expression);
free(filter);
free(event->filter_expression);
free(event->filter);
free(event->exclusion);
- free(event);
+ delete event;
}
/*
/* UST event */
struct ltt_ust_event {
- bool enabled;
- struct lttng_ust_abi_event attr;
- struct lttng_ht_node_str node;
- char *filter_expression;
- struct lttng_bytecode *filter;
- struct lttng_event_exclusion *exclusion;
+ bool enabled = false;
+ struct lttng_ust_abi_event attr = {};
+ struct lttng_ht_node_str node = {};
+ char *filter_expression = nullptr;
+ struct lttng_bytecode *filter = nullptr;
+ struct lttng_event_exclusion *exclusion = nullptr;
/*
* An internal event is an event which was created by the session daemon
* through which, for example, events emitted in Agent domains are
* "funelled". This is used to hide internal events from external
* clients as they should never be modified by the external world.
*/
- bool internal;
+ bool internal = false;
};
/* UST channel */