harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [classlib] mem
Date Tue, 27 Jun 2006 07:59:10 GMT
Geir Magnusson Jr wrote:
> Tim Ellison wrote:
>> This function is (deliberately) not exported from the hyprt.dll so you
>> cannot call it directly.  You have to call it via the function pointer
>> table ...
> 
> That's the missing element - it's not exported.

The idea is that code should always go via the function table so that
your caller can control your use of these functions.

>> Of course, you can reference that member directly if you so choose, and
>> as written elsewhere if you are dealing with multiple tables the
>> syntactic sugar doesn't help and you must reference it in full.
> 
> When would you have multiple tables?

Very rarely (Jimmy brought it up, so maybe he has an example).  It would
be more common to modify the table before you pass it on, to include a
function that has more debug info (like the callsite version we saw
earlier), or allocates from a given memory pool, or limits the amount of
resource you can have, runs on a certain processor, etc. etc.

>> I guess that the confusion is caused by the HyPortLib struct containing
>> a member called 'mem_allocate_memory' that has the address of a function
>> called 'hymem_allocate_memory'?
> 
> really it was having a macro and a function named the same, differing
> only by a number of arguments where the macro expanded out to what has
> the potential of being something very different than the function
> because of the function table.  It wasn't obvious that the function
> wasn't exported (of course).

Right.  As you see, the macro names follow a convention that matches the
default table value function name -- once you are comfortable with that
programming using the macros is not much different to programming direct
to the function itself (modulo first portlib arg).

Regards,
Tim

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message