| Christopher Smith on 4 Jul 2003 08:48:01 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: [ALACPP] smart pointers in C |
Josh Dybnis wrote:Umm... pretty much any OS or GUI environment provides you with handles, which are typically some kind of an int which provides an indirect reference (typically through a lookup table of some kind) to the real pointer. Functions are provided for opening, copying (well, not always copying) and closing the handle. Each of the functions updates internal structures which manage the actual resources the handle is associated with, including ref-counts. Typically you never get direct access to the real data structure, although in some crazy cases the int's value is the same as the address value of the pointer. Because you are dealing with C instead of C++, using the copy operator will simply do a bitwise copy without updating any refs. Also, you don't have destructors, so you have to explicitly ensure that you close a handle before it falls out of scope.--- Christopher Smith <x@xxxxxxxx> wrote: Like I said, it isn't pretty, but it essentially provides a resource management abstraction. --Chris |