Re: [PATCH v6 1/4] last-modified: new subcommand to show when files were last modified
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Aug 2, 2025, 13:38 UTC
- Message-ID
- <CAP8UFD0Hrb-=TRNkueBw06Mgu6Hp1zO8qZVOFVLi8Qp4xkas+w@mail.gmail.com>
- In-Reply-To
- <CAP8UFD1hdykpEaFrs1VoHbU1f-vT7xL2R6uvFWzjPQKRp0eoEw@mail.gmail.com>
On Sat, Aug 2, 2025 at 1:31 PM Christian Couder <christian.couder@gmail.com> wrote:
Show 26 quoted lines
> Q: Do you have other examples than strbuf_release using "release" > where the function behaves like a "clear" function? > > A: > > Yes – a handful of other helpers are spelled “*_release()”, yet they > merely clear the inside of an on‑stack/object‑lifetime struct and > leave the container itself reusable > > - Line reader: void line_buffer_release(struct line_buffer *buf); > Closes the underlying file descriptor and frees its internal scratch > space; the struct line_buffer itself remains valid and can be > re‑initialised with line_buffer_open() if desired. > > - Packet‑line writer: void packet_writer_release(struct packet_writer *writer); > Calls strbuf_release(&writer‑>scratch_buf) and clears a few flags; > the struct packet_writer lives on so the caller may point it at > another FILE * later. > > - FS‑monitor IPC channel: void fsmonitor_ipc__release(struct > fsmonitor_ipc *ipc); > Shuts down the socket, frees small temp buffers, and zeroes the > struct for re‑use inside the long‑running daemon. > > All of these match the behaviour of strbuf_release() rather than that > of the many *_free() helpers which actually free() the struct itself.
Actually it looks like it hallucinated those examples. It's true that strbuf_release() makes it possible to reuse the struct, but it's not efficient as memory needs to be reallocated.
Sorry for the noise.