X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fkernel.c;h=afa5e604fbefff9a9a2465fb5809cfe884d19f60;hp=a8fd844d961d06dc41a2dae3450839039fa157a6;hb=db7586006bc1a2b9057a2c108bf1e7d20fd6903f;hpb=10a8a2237343699e3923d87e24dbf2d7fe225377 diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index a8fd844d9..afa5e604f 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -24,9 +24,8 @@ #include #include +#include #include -#include -#include #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");