Tests: fix: schedule api: leak of rotation schedule list
[lttng-tools.git] / src / bin / lttng-sessiond / rotation-thread.cpp
index 2f89fbc64ee875f8e94f5efc78b34e6a57648575..ac75f58abab75bf24e0a25b817070c0bfc2aa5ca 100644 (file)
@@ -47,13 +47,6 @@ struct rotation_thread {
        struct lttng_poll_event events;
 };
 
-struct rotation_thread_job {
-       enum rotation_thread_job_type type;
-       struct ltt_session *session;
-       /* List member in struct rotation_thread_timer_queue. */
-       struct cds_list_head head;
-};
-
 /*
  * The timer thread enqueues jobs and wakes up the rotation thread.
  * When the rotation thread wakes up, it empties the queue.
@@ -72,6 +65,15 @@ struct rotation_thread_handle {
        struct lttng_pipe *quit_pipe;
 };
 
+namespace {
+struct rotation_thread_job {
+       enum rotation_thread_job_type type;
+       struct ltt_session *session;
+       /* List member in struct rotation_thread_timer_queue. */
+       struct cds_list_head head;
+};
+} /* namespace */
+
 static
 const char *get_job_type_str(enum rotation_thread_job_type job_type)
 {
@@ -89,7 +91,7 @@ struct rotation_thread_timer_queue *rotation_thread_timer_queue_create(void)
 {
        struct rotation_thread_timer_queue *queue = NULL;
 
-       queue = (rotation_thread_timer_queue *) zmalloc(sizeof(*queue));
+       queue = zmalloc<rotation_thread_timer_queue>();
        if (!queue) {
                PERROR("Failed to allocate timer rotate queue");
                goto end;
@@ -134,7 +136,7 @@ struct rotation_thread_handle *rotation_thread_handle_create(
 {
        struct rotation_thread_handle *handle;
 
-       handle = (rotation_thread_handle *) zmalloc(sizeof(*handle));
+       handle = zmalloc<rotation_thread_handle>();
        if (!handle) {
                goto end;
        }
@@ -193,7 +195,7 @@ void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue,
                goto end;
        }
 
-       job = (rotation_thread_job *) zmalloc(sizeof(struct rotation_thread_job));
+       job = zmalloc<rotation_thread_job>();
        if (!job) {
                PERROR("Failed to allocate rotation thread job of type \"%s\" for session \"%s\"",
                                job_type_str, session->name);
This page took 0.026801 seconds and 4 git commands to generate.