[llvm] r200040 - Make ObjectFile ownership of the MemoryBuffer optional.
Alp Toker
alp at nuanti.com
Fri Jan 24 14:27:45 PST 2014
On 24/01/2014 22:05, Rafael EspĂndola wrote:
>> Managing MemoryBuffer lifetimes this way seems unsatisfactory. Would it be
>> possible to refcount or use some kind of smart pointer?
> Binary could hold a OwningPtr<MemoryBuffer> and call take if it is not
> owning it, but that seems equivalent.
>
> I would avoid reference counts as much as possible. It is always the
> case that the Binary can own it or the caller can.
I'm not sure exactly what would be an improvement but it doesn't seem
great to have three manual buffer deletes. I guess let's just keep an
eye open for options here.
Refcounting isn't great either because it becomes less clear who's
holding the allocation. Perhaps we want something like a MemoryBuffer
dup facility or centralized management of mapped files? Feels like we're
missing a good solution in various parts of LLVM right now using
MemoryBuffer.
Alp.
--
http://www.nuanti.com
the browser experts
More information about the llvm-commits
mailing list