From: Carl Daniel (cpdaniel_at_[hidden])
Date: 2002-03-26 14:59:34
From: "E. Gladyshev" <egladysh_at_[hidden]>
> > Of course, there is NO way to determine how memory
> > was allocated. IMO, a properly designed module
> > interface will NEVER
> > delegate resource management responsibility to it's
> > clients. If a DLL function allocates memory (or any
> > other resource)
> > , the DLL must also expose a function to reclaim
> > that memory (or resource) - any other combination is
> > simply a time-bomb
> > waiting to go off.
> I totally agree. Unfortunately
> clients allocate and manage the memory
> quite often and many C interfaces
> are designed around this requirements.
> A simple example is waveInOpen() in Win32 MM SDK.
> This function accepts a pointer to WAVEFORMATEX
> structure. The sturcture has to be allocated
> and managed by the client.
That's fine - client allocates/client frees. The reverse is fine too: DLL allocates/DLL frees. The problematic cases
are Client allocates/DLL frees, and DLL allocates/Client frees.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk