Re: [DynInst_API:] [RFC PATCH] Cleanup warnings


Date: Fri, 29 Apr 2016 17:16:56 -0500
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] [RFC PATCH] Cleanup warnings
On 04/29/2016 05:08 PM, Peter Foley wrote:
On Fri, Apr 29, 2016 at 5:24 PM, Bill Williams <bill@xxxxxxxxxxx> wrote:
And a general note for developers: we should prefer using scoped_ptr and a
custom destructor for file descriptors and other such things where we're
going to error-check, clean up, and bail multiple times in a function. Code
then becomes:

scoped_ptr<FILE*> f(fopen(whatever), &fclose);

if(!fseek(stuff)) return false;
if(fwrite(stuff) < 0) return false;

Somewhat less error-prone, closes the same way no matter how you exit the
function. It's not an idiom we use at all yet, but seeing this list of fixes
reminded me that we really should.
Looks like scoped_ptr doesn't let you specify a deleter.
http://www.boost.org/doc/libs/1_60_0/libs/smart_ptr/scoped_ptr.htm

Did you maybe mean shared_pointer?
Yes, shared will do; I could have sworn scoped also supported deleters at some point but I may be assigning more consistency to boost than is due...
[← Prev in Thread] Current Thread [Next in Thread→]