This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH RFC 4/5] Introduce scoped_mmapped_file
- From: Simon Marchi <simon dot marchi at polymtl dot ca>
- To: Tom Tromey <tom at tromey dot com>
- Cc: Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches at sourceware dot org
- Date: Tue, 12 Jun 2018 21:36:21 -0400
- Subject: Re: [PATCH RFC 4/5] Introduce scoped_mmapped_file
- References: <1525901216-15031-1-git-send-email-simon.marchi@ericsson.com> <1525901216-15031-5-git-send-email-simon.marchi@ericsson.com> <87y3grz0px.fsf@tromey.com> <1601635db4edc8926dfcf2a82db65c3e@polymtl.ca>
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