3 ms·
It looks great and useful. I suspect that this only works within a single translation unit and can't work between separate translation units. But maybe it could
by leni536 7y ago
It looks great and useful. I suspect that this only works within a single translation unit and can't work between separate translation units. But maybe it could work together with lto, that would be pretty awesome.
Some of the worst lifetime issues are 3rd party library calls with unclear ownership semantics and static analyzers are just as clueless as you are. The function signature doesn't help you out in this regard (in C). My recent "favorite" is libzip's zip_open_from_source that conditionally takes ownership of its zip_source_t* argument.
https://libzip.org/documentation/zip_open_from_source.html https://libzip.org/documentation/zip_open_from_source.html
https://libzip.org/documentation/zip_source_free.html https://libzip.org/documentation/zip_source_free.html