Variable dimensioning in fortran (now in C)

Leo de Wit leo at philmds.UUCP
Thu Jun 30 08:35:59 AEST 1988


In article <760 at naucse.UUCP> rrr at naucse.UUCP (Bob Rose ) writes:
  [calloc stuff deleted]...
|You misunderstood me. (A lot of people have been doing that lately,
|maybe I need a vacation :-) Calloc is available every where except on
|systems totally brain damaged. The thing is calloc binary zero's the
|memory. The array you where zeroing was of type double. Now no where
|does it say that the internal representation of a double must be binary
|zero (most machines it is, but NOT all.) This turns out to be one of
|those hard to find bugs when porting to an odd ball architecture.

As a matter of fact, the calloc() came from someone else's article.
That person used a calloc for each row of the array and a calloc for
the array of pointers to the rows. I didn't even bother to change them
to malloc's which I use myself normally; perhaps to make the comparing
easier (how's that for an excuse ? ;-).

As for initialization, I think it is better to have that as a separate
function; there may just be cases in which it is inefficient to first
set all values to zero, then fill it with values.

|| |Just fuel for the fire.
|| Thanks! So I can light my cigar now 8-).
|| 
||                    Leo++
|
|So did I make myself clear or should I buy you a box of cigars for the
|long battle ahead :^)
|                     --bob

Make it a pipe of peace. And now you did it (to) yourself:
you made yourself clear using calloc 8-)
(but that's allowed in this case, you being an integer person, not some
double-crosser %-).

                    !!leo



More information about the Comp.lang.c mailing list