[PATCH RFC 4/5] Introduce scoped_mmapped_file

Simon Marchi simon.marchi@polymtl.ca
Wed Jun 13 01:36:00 GMT 2018


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



More information about the Gdb-patches mailing list