From: Kris Van Hees <kris.van.hees@oracle.com>
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: [PATCH 07/20] libdtrace: reuse the built-in module range line buffer
Date: Fri, 30 Oct 2026 19:36:39 +0000 [thread overview]
Message-ID: <39f8bf63bedf882b1101174da917d6b8@oracle.com> (raw)
---
libdtrace/dt_module.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libdtrace/dt_module.c b/libdtrace/dt_module.c
index bd92d126..6868268e 100644
--- a/libdtrace/dt_module.c
+++ b/libdtrace/dt_module.c
@@ -1588,6 +1588,8 @@ typedef struct dt_kasstate {
GElf_Addr mod_saddr, mod_eaddr;
char mod_name[PATH_MAX];
FILE *rfp;
+ char *line;
+ size_t line_n;
int kind;
int kernel_flag;
@@ -1630,8 +1632,7 @@ dt_kasstate_new(dtrace_hdl_t *dtp, int kind)
static char *
dt_kasstate_modname(dt_kasstate_t *state, GElf_Addr addr, const char *name)
{
- char *line = NULL;
- size_t line_n = 0;
+ char *line;
/* Nothing to be done if there is no modules.builtin.ranges file. */
if (state->rfp == NULL)
@@ -1658,9 +1659,10 @@ dt_kasstate_modname(dt_kasstate_t *state, GElf_Addr addr, const char *name)
* is found that either contains the address or goes beyond.
*/
while (addr > state->mod_eaddr) {
- if (getline(&line, &line_n, state->rfp) == -1)
+ if (getline(&state->line, &state->line_n, state->rfp) == -1)
break;
+ line = state->line;
if (sscanf(line, "%*s %lx-%lx %[A-Za-z0-9_ ]",
&state->mod_saddr, &state->mod_eaddr,
state->mod_name) == 3) {
@@ -2051,6 +2053,7 @@ dtrace_update(dtrace_hdl_t *dtp)
if (state->rfp)
fclose(state->rfp);
+ free(state->line);
dt_free(dtp, state);
}
--
2.52.0
reply other threads:[~2026-10-30 19:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=39f8bf63bedf882b1101174da917d6b8@oracle.com \
--to=kris.van.hees@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
/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 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.