libdtrace: reuse the built-in module range line buffer
PATCH 7/20 libdtrace: reuse the built-in module range line buffer
--- libdtrace/dt_module.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
libdtrace/dt_module.c +6 -3
@@ -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); }
Signature · 1 line
2.52.0
On 30 Oct 2026, Kris Van Hees verbalised:
Quoted 3 lines
--- libdtrace/dt_module.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Reviewed-by Nick Alcock <[email protected]>
Signature · 1 line
NULL && (void)