>>101
関数の中で realloc 使うときはよく注意すること...

int *ptr, *tmp;

ptr =(int *)malloc( sizeof( int ) * 10 );
tmp =(int *)realloc( ptr, sizeof( int ) * 30 );

なとき、ptr == tmp とは限らないので。

void extend( int *array, size_t len )
{
int *tmp;

tmp =(int *)realloc( array, sizeof( int ) * len );
}

とかやってると、はまる。

void *ptr;

ptr =(int *)malloc( sizeof( int ) * 10 );
extend( ptr, 30 );
memcpy( ptr, "hello, world!", 14 ); /* SIGSEGV だったりして */