RE: allocation of untagged structures

From: [at]} <frei{>
Date: Mon, 30 Dec 2002 22:35:17 +0100

----boundary-LibPST-iamunique-1224390164_-_-
Content-type: text/plain

Doug,

basically, you have two alternatives:

(1.) use normal tagged pointer types and NEW. But then, as you already
noticed, you have to be very careful about interferences between the
normal BlackBox garbage collector and COM reference counting. Jurg
Gutknecht describes a solution for this problem in his report "Oberon as
an Implementation Language for COM Components: A Case Study in Language
Interoperability". There, the entirety of objects currently in use by
COM is linked to a ring via prev/next pointers in order to prevent the
garbage collector from reclaiming objects used by COM but not by Oberon.
This ring must be anchored in a global variable.

(2.) use untagged pointers and the Windows memory management procedures
(HeapAlloc, HeapFree, etc.). There are also special COM memory
management procedures (CoTaskMemAlloc, CoTaskMemFree, etc.). The latter
procedures are mandatory for allocating [out] and [in, out] pointer
parameters. This is explained in more detail in Dale Rogerson's book
Inside COM or in Don Box's Essential COM.

Best regards,
Marc,
Oberon microsystems, Inc.


-----Original Message-----
From: Douglas G. Danforth [mailto:danforth{([at]})nowhere.xy
Sent: Sonntag, 29. Dezember 2002 18:06
To: blackbox{([at]})nowhere.xy
Subject: allocation of untagged structures


Folks,

I am attempting to do a very simple COM interface following
the suggestion in Platform-Specific Issues Using COM without
special Direct-To-COM compiler.

I had thought this would be easy but NEW cannot be used
to allocate untagged structures which are needed by COM.
So how can I allocate an arbitrary number of instances
of a COM object?

Must I count the number of bytes in the data structure
desired then allocate a BYTE array of that size
using NEW and then assign the address of the first
element of that array to an untagged pointer?

That doesn't seem too safe for when releasing the
data when the reference count goes to zero I somehow
must recapture the actual pointer to the BYTE array
and set it to zero for actual garbage collection.

How do I keep the reference count and garbage collection
processes separate?

-Doug
--------------------------------------------

To unsubscribe from this mailing list, send a message containing the
word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage,
send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the
list owner at
   owner-blackbox{([at]})nowhere.xy

Current posting policy:

a) To post you should use the same address by which you are subscribed
to the mailing list. That way, the list server will recognize you as
subscriber and forward your posting immediately, without creating any
overhead.

b) If, for some reason, you cannot post from the address, by which you
are subscribed, your message will be moderated to avoid spam. Please
understand that moderation will often cause some delay, in particular
over weekends or holydays.

--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy

Current posting policy:

a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.

b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.


----boundary-LibPST-iamunique-1224390164_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIERvdWcsXHBhcg0KXHBhcg0KYmFzaWNhbGx5LCB5
b3UgaGF2ZSB0d28gYWx0ZXJuYXRpdmVzOlxwYXINClxwYXINCigxLikgdXNlIG5vcm1hbCB0YWdn
ZWQgcG9pbnRlciB0eXBlcyBhbmQgTkVXLiBCdXQgdGhlbiwgYXMgeW91IGFscmVhZHlccGFyDQpu
b3RpY2VkLCB5b3UgaGF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