Instead of adding an aliased display name and having to maintain it and treat it differently, go back to keeping the name only in the "control" sub-structure of the state, but share the global state "control" across all watched fds, and just change it before each pv_display() call so it points to the relevant fd display_name when needed (#165).

This commit is contained in:
Andrew Wood
2025-07-27 21:23:41 +01:00
parent 5282a521b5
commit 574ea04502
6 changed files with 16 additions and 53 deletions
-10
View File
@@ -245,14 +245,6 @@ struct pvstate_s {
/*****************
* Display state *
*****************/
/*
* Note that the "name" pointer is an alias - it should point to
* some other string that's allocated and freed separately, such as
* control.name. It is used here so that the name can be changed
* for different display structures without having to also change
* the control structure, for example when watching multiple file
* descriptors with --watchfd.
*/
struct pvdisplay_s {
struct pvdisplay_segment_s { /* format string broken into segments */
@@ -281,8 +273,6 @@ struct pvstate_s {
off_t initial_offset; /* offset when first opened (when watching fds) */
size_t next_line_len; /* length of currently receiving line so far */
/*@dependent@*/ /*@null@*/ const char *name; /* copy of pointer to string for %N */
size_t format_segment_count; /* number of format string segments */
pvtransfercount_t count_type; /* type of count for transfer, rate, etc */