Memory allocated for structs returned to the user should be allocated in a way that it's persistent 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().
Memory allocated for structs returned to the user should be allocated in a way that it's persistent 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 byFromStructPtr()
, 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 thoseRelease*()
methods, e.g.ITypeInfo::ReleaseFuncDesc()
.Summary:
Add:StructBase.GetOriginalPointer()
StructBase.ReleaseOriginalPointer()
Struct classes & StructBase:FromStructPtr()
to store the pointerCCFramework.AllocateMemory()
, notVarSetCapacity()
.Check:How far this affects nested structures...