Disposing generic pointers
John L. Ries
jries at salford-systems.com
Tue Apr 6 18:47:34 CEST 2010
On Tue, 6 Apr 2010, Adriaan van Os wrote:
> John L. Ries wrote:
>> On Tue, 6 Apr 2010, Adriaan van Os wrote:
>>
>>> John L. Ries wrote:
>>>
>>>> Since the unit in question is supposed to work with whatever data type
>>>> is thrown at it (it is intended to be generic set of queuing routines),
>>>
>>> But how are the queue elements allocated ?
>>>
>> By the calling program. All the queue unit ever sees are pointers and
>> its own infrastructure.
>
> But then, I think it would be good style to add a call to the unit that
> does the allocation - if you really want the unit to be generic, as you
> write. After all, it is possible that the calling program chooses an
> allocater that is incompatible with the deallocator in the unit.
>
Perhaps. In general, it is the calling program that is expected to
deallocate the elements (after dequeueing them). The procedure I sent in
my initial message is intended to delallocate a queue that might not be
empty, though normally it would be (but it is still a good idea to check).
It is actually the only routine in the unit that deallocates elements.
Possibly, for Borland compatibility, I will need to add an argument to the
procedure that gives the element length, but that is a lot more C-ish than
I like.
--------------------------|
John L. Ries |
Salford Systems |
Phone: (619)543-8880 x107 |
or (435)867-8885 |
--------------------------|
More information about the Gpc
mailing list