Linux DTrace development list
 help / color / mirror / Atom feed
* [PATCH 07/20] libdtrace: reuse the built-in module range line buffer
@ 2026-10-30 19:36 Kris Van Hees
  0 siblings, 0 replies; only message in thread
From: Kris Van Hees @ 2026-10-30 19:36 UTC (permalink / raw)
  To: dtrace, dtrace-devel

---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-30 19:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 19:36 [PATCH 07/20] libdtrace: reuse the built-in module range line buffer Kris Van Hees

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox