maul-esel/COM-Classes — Issue #15: allocate persistent memory for structs
Author: maul-esel
Created: 2012-01-22 21:21:27+00:00
State: open
Labels: code, improvement

Memory allocated for structs returned to the user should be allocated in a way that it's persitent after the method returns.

To do so, allocate the memory using the "Heap functions" (`CCFramework.AllocateMemory()`). Also add a new method to structs: `GetOriginalPointer()`, which, if the instance was created by `FromStructPtr()` returns the pointer it was created from (which only makes sense if it's still valid).

The user is responsible for releasing the memory (add a `ReleaseOriginalPointer()` method). In case of the TypeInfo structs, this allows struct instances to be passed to those `Release*()` methods, e.g. `ITypeInfo::ReleaseFuncDesc()`.

### Summary:
* Add:
* `StructBase.GetOriginalPointer()`
* `StructBase.ReleaseOriginalPointer()`
* Modify:
* Struct classes & StructBase: `FromStructPtr()` to store the pointer
* COM methods: allocate memory with `CCFramework.AllocateMemory()`, not `VarSetCapacity()`.
* Check:
* How far this affects nested structures...