maul-esel / COM-Classes

AHK classes that implement COM interfaces
39 stars 10 forks source link

allocate persistent memory for structs #15

Closed maul-esel closed 12 years ago

maul-esel commented 12 years ago

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:

maul-esel commented 12 years ago