From: Linuxer W. <lin...@gm...> - 2005-05-31 18:25:36
|
Hello, all I read part of the source codes, I have a problem with function find_neighbors() in file neighbors.c. I marked the problems lines as @1 and @2 as follows: if( neighbor_item.score > threshold) { if ( (neighbor_item.vector = malloc(vector_size)) == NULL ) { <---------@1 fprintf( stderr, "neighbors.c: can't allocate vector memory.\n" ); free_tail( list, neighbor_item_free ); return 0; } list_insert( list, &last, depth, <---------@2 (void *) &neighbor_item, sizeof( NEIGHBOR_ITEM ), neighbor_item_cmp, neighbor_item_free ); list_length++; /* Set the threshold to the lowest value in the list */ if( (last != NULL) && (list_length >= depth)) threshold = ((NEIGHBOR_ITEM *) (last->data))->score; } Note that, @1 clears the vector of neighbor_item, so when @2 tries to insert neighbor_item to the list, the vector of neighbor_item is already zero array. So the problem is that the order of @1 and @2 should be conversed. The current codes cause the output to file contains only zeros. Can anyone verify it? Yours, |