public_variable_neighborhood/public_variable_neighborhood.h
/**
 * Goes through the neighborhood entries and removes all entries that are above the maximum age of neighbor informations.
 * Has to be called frequently
 */
Goes through the neighborhood entries and removes all entries that are above the maximum age of neighbor informations.
Has to be called frequently
Goes through the neighborhood entries and removes all entries that are above the maximum age of neighbor informations . Has to be called frequently
void pvn_remove_old_neighbor_information(struct PVN* pvn)
{
	unsigned long oldest_timestamp_allowed = clock_seconds()-pvn->maximum_age_of_neighbor_information;
	if(clock_seconds()<=pvn->maximum_age_of_neighbor_information) oldest_timestamp_allowed = 0;
	struct Nbr* nbr = pvn_getNbrs(pvn);
	while(nbr!=0) {
		if(nbr->timestamp<oldest_timestamp_allowed) {
			if(pvn->callbacks.onDelete!=0) {
				(*(pvn->callbacks.onDelete))(nbr);
				pvn->neighborhood_size--;
			}
			pvn->nbrList = pvn_getNextNbr(nbr);
			free(nbr->public_var);
			free(nbr);
			nbr = pvn_getNbrs(pvn);
		} else {
			break;
		}
	}
	for(; nbr!=0 && pvn_getNextNbr(nbr)!=0; nbr= pvn_getNextNbr(nbr)) {
		if(nbr->nextNbr->timestamp<oldest_timestamp_allowed) {
			struct Nbr* tmp = nbr->nextNbr;
			if(pvn->callbacks.onDelete!=0) {
				(*(pvn->callbacks.onDelete))(tmp);
				pvn->neighborhood_size--;
			}
			nbr->nextNbr = nbr->nextNbr->nextNbr;
			free(tmp->public_var);
			free(tmp);
		}
	}
	return;
}
void pvn_remove_old_neighbor_information ( struct PVN * pvn ) { unsigned long oldest_timestamp_allowed = clock_seconds ( ) - pvn -> maximum_age_of_neighbor_information ; if ( clock_seconds ( ) <= pvn -> maximum_age_of_neighbor_information ) oldest_timestamp_allowed = 0 ; struct Nbr * nbr = pvn_getNbrs ( pvn ) ; while ( nbr != 0 ) { if ( nbr -> timestamp < oldest_timestamp_allowed ) { if ( pvn -> callbacks . onDelete != 0 ) { ( * ( pvn -> callbacks . onDelete ) ) ( nbr ) ; pvn -> neighborhood_size -- ; } pvn -> nbrList = pvn_getNextNbr ( nbr ) ; free ( nbr -> public_var ) ; free ( nbr ) ; nbr = pvn_getNbrs ( pvn ) ; } else { break ; } } for ( ; nbr != 0 && pvn_getNextNbr ( nbr ) != 0 ; nbr = pvn_getNextNbr ( nbr ) ) { if ( nbr -> nextNbr -> timestamp < oldest_timestamp_allowed ) { struct Nbr * tmp = nbr -> nextNbr ; if ( pvn -> callbacks . onDelete != 0 ) { ( * ( pvn -> callbacks . onDelete ) ) ( tmp ) ; pvn -> neighborhood_size -- ; } nbr -> nextNbr = nbr -> nextNbr -> nextNbr ; free ( tmp -> public_var ) ; free ( tmp ) ; } } return ; }
Goes through the neighborhood entries and removes all entries that are above the maximum age of neighbor informations.
Goes through the neighborhood entries and removes all entries that are above the maximum age of neighbor informations .
//remove the outdated entries in the beginning such that the list is either empty or the first entry is not outdated //delete nbr //Notify //remove the outdated entries further behind //Notify