> - 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.