harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geir Magnusson Jr <g...@pobox.com>
Subject Re: [classlib] mem
Date Mon, 26 Jun 2006 14:15:43 GMT


Tim Ellison 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)"? 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 think the second style is more readable, so would advocate using that.
> 
> As you say, the readable macros are set up using the PORT_ACCESS_FROM_*
> directives, so that you can use them if you are passed different types.
> 
> PORT_ACCESS_FROM_ENV(JNIEnv)      - you have a JNIEnv struct ptr
> PORT_ACCESS_FROM_JAVAVM(JavaVM)   - you have a JavaVM struct ptr
> PORT_ACCESS_FROM_PORT(portlib)    - you have a portlib ptr

Except...

1) They aren't as Jimmy suggests, at least the one's I'm looking at.

2) the implementation in hymem.c just calls malloc()

I'm confused.

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


Mime
View raw message