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


Date: Fri, 29 Apr 2016 18:08:06 -0400
From: Peter Foley <pefoley2@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] [RFC PATCH] Cleanup warnings
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?
[← Prev in Thread] Current Thread [Next in Thread→]