[PATCH 0/2] libtracefs: Have string lists contain their size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Have the string lists contain the size inside them.

The way this is done is by allocating one pointer than the user needs:

/* just pseudo code of the idea, no error checking */
 if (!list) {
	list = malloc(sizeof(*list) * 3);
	list[0] = (char *)1;
	list[1] = strdup(users_string);
	list[2] = NULL;
	return &list[1];
 }
 list--;
 size = *(unsigned long *)list;
 tmp = realloc(list, sizeof(*list) * (size + 3));
 list = tmp;
 list[0] = (char *)(size + 1);
 list++;
 list[size++] = strdup(users_string);
 list[size] = NULL;
 return list;

Implementing this has fixed a few bugs and memory leaks.

Steven Rostedt (VMware) (2):
  libtracefs: Move tracefs_list_free() to tracefs-utils.c
  libtracefs: Restructure how string lists work

 include/tracefs-local.h |  1 +
 include/tracefs.h       |  4 +-
 src/tracefs-events.c    | 61 ++++++++++--------------------
 src/tracefs-instance.c  |  9 +----
 src/tracefs-kprobes.c   | 17 ++-------
 src/tracefs-tools.c     |  6 +--
 src/tracefs-utils.c     | 83 +++++++++++++++++++++++++++++++++++++++++
 7 files changed, 112 insertions(+), 69 deletions(-)

-- 
2.30.2




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux