Rename lttngerr.h to error.h
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index a8fd844d961d06dc41a2dae3450839039fa157a6..afa5e604fbefff9a9a2465fb5809cfe884d19f60 100644 (file)
@@ -24,9 +24,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <common/common.h>
 #include <common/kernel-ctl/kernel-ctl.h>
-#include <common/lttngerr.h>
-#include <common/lttng-share.h>
 
 #include "kernel.h"
 
@@ -574,15 +573,15 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
         * Init memory size counter
         * See kernel-ctl.h for explanation of this value
         */
-       nbmem = KERNEL_EVENT_LIST_SIZE;
+       nbmem = KERNEL_EVENT_INIT_LIST_SIZE;
        elist = zmalloc(sizeof(struct lttng_event) * nbmem);
 
        while ((size = fscanf(fp, "event { name = %m[^;]; };%n\n", &event, &pos)) == 1) {
-               if (count > nbmem) {
+               if (count >= nbmem) {
                        DBG("Reallocating event list from %zu to %zu bytes", nbmem,
-                                       nbmem + KERNEL_EVENT_LIST_SIZE);
-                       /* Adding the default size again */
-                       nbmem += KERNEL_EVENT_LIST_SIZE;
+                                       nbmem * 2);
+                       /* Double the size */
+                       nbmem <<= 1;
                        elist = realloc(elist, nbmem * sizeof(struct lttng_event));
                        if (elist == NULL) {
                                perror("realloc list events");
This page took 0.023406 seconds and 4 git commands to generate.