#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"
* 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");