<div dir="ltr">A MutableMemoryBuffer need not be backed by mmap.  For example, you could just allocate some scratch bytes from the heap.  Allowing something like this to work with the same interface as an mmap is one of the primary advantages IMO, because it means you don't have to have different code paths for mmap and malloc.  <br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 21, 2017 at 9:58 AM Rafael Avila de Espindola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When should a MutableMemoryBuffer (or MemoryBuffer) be used instead of<br>
mapped_file_region?<br>
<br>
My original understanding was that mapped_file_region is for when the<br>
user needs a real mmap (readwrite maping) or as a MemoryBuffer<br>
implementation detail.<br>
<br>
All other uses should use the MemoryBuffer indirection as it handles<br>
small files, "volatile" files, etc.<br>
<br>
But I see a few direct uses of mapped_file_region in the code<br>
base. Assuming those uses are a mistake, this patch is probably fine.<br>
<br>
> +ErrorOr<std::unique_ptr<WritableMemoryBuffer>><br>
> +WritableMemoryBuffer::getFile(const Twine &Filename, int64_t FileSize,<br>
> +                              bool RequiresNullTerminator, bool IsVolatile) {<br>
<br>
Do you need RequiresNullTerminator and IsVolatile for rw buffers? If not<br>
I would suggest leaving those out first and seeing if anyone requests<br>
them.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div>