harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Deakin <oliver.dea...@googlemail.com>
Subject Re: [classlib] mem
Date Mon, 26 Jun 2006 15:03:47 GMT
Geir Magnusson Jr wrote:
> Jimmy, Jing Lv wrote:
>   
>> Geir Magnusson Jr wrote:
>>     
>>> Why would I use
>>>
>>> portLib->mem_allocate_memory(portLib....)
>>>
>>> over just calling
>>>
>>> hymem_allocate_memory(portlib, ....)
>>>
>>>       
>> Hi Geir:
>>
>>    Not sure if the later is "hymem_allocate_memory(int size)"? 
>>     
>
> Well, the one I'm looking at is
>
> hymem.c
>
> void *VMCALL
> hymem_allocate_memory (struct HyPortLibrary *portLibrary,
>  		UDATA byteAmount)
>
>
> If so,
>   
>> they are the same indeed, and the later is the a macro. Everytime before
>> we use the macro, call "PORT_ACCESS_FROM_ENV (env)"
>>    e.g.:
>>    somemethod(JNIEnv * env, ...){
>>     PORT_ACCESS_FROM_ENV (env);
>>     ...
>>     hymem_allocate_memory(sizeof(something));
>>     ...
>>    }
>>
>>    And they are defined in hyport.h. :)
>>     
>
> I've heard this rumor before, but I don't ever see how.
> PORT_ACCESS_FROM_* is a simple little macro that just returns *portLib.
>   

yeah, that's right - the PORT_ACCESS_FROM_* macro (defined
in hyport.h) sets the pointer privatePortLibrary to address the relevant 
port library.

Also defined in hyport.h is hymem_allocate_memory(param1) (the single param
function Jimmy was talking about) which is a macro defined to be:
privatePortLibrary->mem_allocate_memory(privatePortLibrary, param1).

So the call to PORT_ACCESS_FROM_* sets up a port library pointer, and the
macro versions of the hymem calls automatically add it in as the first 
parameter
to the relevant function call.

Regards,
Oliver

> geir
>
>   
>>> geir
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>>
>>>
>>>       
>>     
>
> ---------------------------------------------------------------------
> 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
>
>
>   

-- 
Oliver Deakin
IBM United Kingdom Limited


---------------------------------------------------------------------
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