From: Anthony Williams (anthony.williamsNOSPAM_at_[hidden])
Date: 2003-02-21 03:43:54
"Phil Nash" <phil.nash.lists_at_[hidden]> writes:
> [Anthony Williams]
> > On Windows, for example, you can use GlobalAlloc to allocate some memory,
> > you get an HGLOBAL back --- a handle to the memory. You need to call
> > GlobalLock with that handle to get a pointer to the memory which you can
> > actually use. The resource manager therefore needs to keep track of the
> > handle, rather than the pointer (which may be different after different
> > to GlobalLock, if there has been an intervening GlobalUnlock). Indeed, the
> > pointer to the locked memory is essentially a separate resource, acquired
> > GlobalLock() and released with GlobalUnlock. It would be sensible to be
> > to use the same framework for both the handle and the pointer.
> This sounds like a perfect case where using a smart_PTR would be very
> confusing, maybe dangerously so!
> Err.. but just to be sure, are you saying this in support of smart_resource?
Yes. My point was that even something "so simple" as memory can not always
sensibly be managed purely by a smart *pointer* --- you need a resource
manager for the handle.
-- Anthony Williams Senior Software Engineer, Beran Instruments Ltd. Remove NOSPAM when replying, for timely response.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk