Skip to content

Need an ownership_holds for non-malloced memory #132188

Open
@fefe17

Description

@fefe17

I have an API where you can add a buffer to a writev-style array and then later repeatedly ask the API to write what's left of the total buffers to a file descriptor.

There are two functions to add a buffer to the list. One says "free the buffer when you are done", the other says "don't free the buffer when you are done".

Usually you will call the latter one with a string constant, but you might also call it with something malloced, and then I would like to get an error if I free that malloced buffer after adding it to the batch, and I would like to tell clang when the data structure is deinitialized so it can know that it is now OK to free the buffer you gave it.

The first half could be done with a magic identifier for ownership_holds, like currently malloc is. Maybe generic?

But the second half would need a totally new attribute, like ownership_release or so.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions