On Sun, 17 Feb 2002, Segher Boessenkool wrote: > > > Steve Fink wrote: > > > > > - key->keys = (KEY_PAIR*)realloc(key->keys,sizeof(KEY_PAIR)*size); > > > + key->keys = (KEY_PAIR**)realloc(key->keys,sizeof(KEY_PAIR)*size); > > > > That seems rather suspicious. I don't know anything about the KEY_PAIR > > type, but allocating a chunk of memory big enough to fit N structures > > and then using it as an array of pointers to individual structures... > > well, something's fishy. > > That's why it's safer to write > > p = realloc(p, N * sizeof(*p)); > > whenever possible (that is, if p has correct type). > Btw, is the cast necessary? realloc() returns void*, after all... > >
The cast is necessary with the warning level that we have currently :) /J\ -- Jonathan Stowe | <http://www.gellyfish.com> | This space for rent |