public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/100294] New: need attribute takes_ownership
@ 2021-04-27 18:25 felix-gcc at fefe dot de
  0 siblings, 0 replies; only message in thread
From: felix-gcc at fefe dot de @ 2021-04-27 18:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100294

            Bug ID: 100294
           Summary: need attribute takes_ownership
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: felix-gcc at fefe dot de
  Target Milestone: ---

Now that -fanalyzer is here to track leaking memory, I need a way to tell gcc
that a function takes ownership of a pointer.

You could call it takes_ownership or maybe free.

Here's my setup: I have a function that does I/O batching for you. You have a
batch as a context variable, then you add buffers to it, then you write the
whole batch to a descriptor (or callback). The idea is that the descriptor can
point to a non-blocking socket and the abstraction takes care of repeatedly
writing the next bit in the vector after a partial write.

Anyway, I have a function that adds a buffer to the batch, and I have a
function that adds a buffer to the batch plus the batch takes ownership of the
pointer, i.e. when you are done with the batch and close it, all those pointers
will be freed.

-fanalyze now (rightly) complains that I'm leaking the memory of the pointer I
gave to the function that takes ownership.

I need a way to either say "takes ownership" or maybe, even better, a way to
say how the free will happen, so malloc+free matching in gcc 11 can apply.

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

only message in thread, other threads:[~2021-04-27 18:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 18:25 [Bug analyzer/100294] New: need attribute takes_ownership felix-gcc at fefe dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).