From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 0/2] libtracefs: Have string lists contain their size
Date: Fri, 2 Jul 2021 16:34:57 -0400 [thread overview]
Message-ID: <20210702203459.169473-1-rostedt@goodmis.org> (raw)
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
next reply other threads:[~2021-07-02 20:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-02 20:34 Steven Rostedt [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210702203459.169473-1-rostedt@goodmis.org \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).