[GRASS5] New MacOS X compilation errors

Justin Hickey jhickey at hpcc.nectec.or.th
Tue Nov 21 22:28:58 EST 2000


Hi Andreas and all

Andreas Lange wrote:
> Generally the use of G_malloc is preferred over malloc.
> _BUT_ in this case i feel that it is unneccessary to use G_malloc, as
> the code is stable, no debugging is needed etc. And G_malloc will give
> a (slight) overhead due to one function call more.

Hmmm. I think we should be consistent with things like this. Either we
always use G_malloc or we never do. Otherwise we get code like we now
have in grass with some people using G_malloc and others using malloc.
The problem is those using malloc are not always checking if memory was
allocated properly. This is the reason to use G_malloc - to ensure that
the memory was allocated properly.

As for the function call overhead, it is minimal with today's machines
and if I recall correctly, I think I read somewhere that memory
allocation is an expensive operation. Thus, the cost of memory
allocation should outweigh the cost of function call overhead.

I suggest that we should always use G_malloc (and the other allocation
functions - G_calloc etc.) unless it can be shown that using malloc
(with the appropriate check for errors) produces a significant increase
in performance for a particular program. Personally, I don't think that
will happen, but that's just my opinion. We should keep in mind that
consistency is a crucial requirement for robust code.

Anyway that's just my 2 cents worth.

-- 
Sincerely,

Jazzman (a.k.a. Justin Hickey)  e-mail: jhickey at hpcc.nectec.or.th
High Performance Computing Center
National Electronics and Computer Technology Center (NECTEC)
Bangkok, Thailand
==================================================================
People who think they know everything are very irritating to those
of us who do.  ---Anonymous

Jazz and Trek Rule!!!
==================================================================

---------------------------------------- 
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'



More information about the grass-dev mailing list