On Nov 14, 2013, at 9:36 AM, Jeffrey Walton <[email protected]> wrote:

> 
> 
> On Monday, November 4, 2013 12:10:18 PM UTC-5, Arendell wrote:
> MD5 hash;
> byte buffer[2 * MD5::DIGESTSIZE];
>  
> FileSource f(argv[1], true,
>              new HashFilter(hash,
>              new HexEncoder(new ArraySink(buffer,2 * MD5::DIGESTSIZE))));
> 
> Is this way cause a memory leak? 
> No.
> 
> From Readme.txt:
> 
> *** Important Usage Notes ***
> 
> 1. If a constructor for A takes a pointer to an object B (except primitive
> types such as int and char), then A owns B and will delete B at A's
> destruction.  If a constructor for A takes a reference to an object B,
> then the caller retains ownership of B and should not destroy it until
> A no longer needs it. 

That's all well and good, but I think that the OP's question was more along the 
line of th following scenario:
        1) Attempt to allocate and create ArraySink(buffer,2 * MD5::DIGESTSIZE) 
succeeds.
        2) Attempt to allocate and create HexEncoder() succeeds
        3) Attempt to allocate and create HashFilter throws. (say, when 
operator new fails to allocate memory)

What happens to the memory allocated in steps #1 and #2?

-- Marshall

Marshall Clow     Idio Software   <mailto:[email protected]>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly 
moderated down to (-1, Flamebait).
        -- Yu Suzuki

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to