The problem is that (*array)++
doesn't give you the next pointer you allocated, so you can't free it. Your free routine should be:
void freeargpointer(char** array)
{
int i;
for ( i = 0; array[i]; i++ )
free( array[i] );
free( array );
}
Or, similarly,
void freeargpointer(char** array)
{
char **a;
for ( a = array; *a; a++ )
free( *a );
free( array );
}
NOTE: I removed the count
argument since it is unnecessary.