Re: [PATCH RFC 4/5] Introduce scoped_mmapped_file

Simon Marchi
2018-06-13T01:36:35Z

On 2018-05-10 05:10 PM, Simon Marchi wrote:
> On 2018-05-10 16:59, Tom Tromey wrote:
>>>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:
>>
>> Simon> + void reset (int new_fd)
>> Simon> + {
>> Simon> + destroy ();
>> Simon> +
>> Simon> + m_fd = new_fd;
>> Simon> + }
>>
>> I was wondering if this should only destroy() when new_fd!=m_fd.
>> That way self-resetting would not cause a bug.
>
> It probably should, indeed.

I looked into this a bit more, and I think I'll leave it like this. This is
how unique_ptr works (at least libstdc++'s and libc++'s implementations of it),
and that's how our other scoped_* implementations work (scoped_mmap amd ref_ptr).

Simon