pioneerspacesim/pioneer — pull request #803 by johnbartholomew (2011-11-15 06:37:04+00:00)
Title: Smart pointers

This patch series adds a set of smart pointer types:

* `ScopedPtr` is used for unique ownership of a `T` object, allocated with `new` and destroyed with `delete`.
* `ScopedArray` is used for unique ownership of an array of `T` objects, allocated with `new T[]` and destroyed with `delete[]`.
* `ScopedMalloc` is used for unique ownership of a `T` object (or array of `T` objects), allocated with `malloc` (or `calloc` or `realloc`) and deallocated with `free`.
* `RefCountedPtr` is used for shared ownership of a `T` object, where `T` must be a class that derives from `RefCounted`.

Other changes:

* `RefCounted` now deletes itself in `DecRefCount` when the count drops to zero.
* `RefCountedPtr` is used instead of a raw `StarSystem*` in various places where ownership is required. In particular, there are no further calls to `IncRefCount` or `DecRefCount` on `StarSystem` objects except the calls made automatically by `RefCountedPtr`, and those made by `LuaAcquirer`
* `RefCountedPtr` is used instead of a raw `GeoPatchContext*`, and again, there are no remaining calls to `IncRefCount` or `DecRefCount` except those made by `RefCountedPtr`.