All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] libtracefs: Have string lists contain their size
@ 2021-07-02 20:34 Steven Rostedt
  2021-07-02 20:34 ` [PATCH 1/2] libtracefs: Move tracefs_list_free() to tracefs-utils.c Steven Rostedt
  2021-07-02 20:34 ` [PATCH 2/2] libtracefs: Restructure how string lists work Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2021-07-02 20:34 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Steven Rostedt

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-02 20:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 20:34 [PATCH 0/2] libtracefs: Have string lists contain their size Steven Rostedt
2021-07-02 20:34 ` [PATCH 1/2] libtracefs: Move tracefs_list_free() to tracefs-utils.c Steven Rostedt
2021-07-02 20:34 ` [PATCH 2/2] libtracefs: Restructure how string lists work Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.