> Referring back to the archives reveals _many_ discussions on the
> folly of trusting your compiler to properly init things... Sure,
> once ch is calloc()'d you have the structure, but no valid or
> trustable values for the sh_int that is ch->class (could be anything).

malloc(3)
       calloc() allocates memory for an array of  nmemb  elements
       of  size bytes each and returns a pointer to the allocated
       memory.  The memory is set to zero.

Calloc initializes all the bits to zero.. which on every architecture I've 
ever used means that the value of an integer in that memory block will be 
zero.
More likely the problem is recycled memory blocks that still contain old data.
Small point, but I believe it's worth mentioning.

> IMHO trying to do this:
> ch->max_hit = class_table[ch->class].hp_base
> inside of new_char is just plain dumb, until they choose a class
> there is no _valid_ data in that variable. Or is that too simplistic
> a view?

That's perfectly legitimate.
But don't blame the calloc :)  Blame ROM's memory recycling.

--Palrich.

Reply via email to