src/alc_list.c
struct alc_list_node* prepare_insert(alc_rcv_container_t *a_data) {
  struct alc_list_node *my_node;
  struct timeval now;
  double container_age;

  assert(a_data != NULL);
  
  if(a_data->time_stamp.tv_sec == 0) {
    /* mark the timestamp first time the container is inserted */
    get_time_of_day(&(a_data->time_stamp));
    assert(a_data->time_stamp.tv_sec != 0);
  }
  else {
    /* check if the container is too old, in case I discard it */
    get_time_of_day(&now);
    
    container_age =  now.tv_sec  - a_data->time_stamp.tv_sec + 
      (now.tv_usec - a_data->time_stamp.tv_usec ) / 1E6;
    assert(container_age >= 0);

    if(container_age > 3) {
      /* containers older than 3 secs are discarded */
      return NULL;
    } 
  }
  
  my_node = malloc(1 * sizeof(struct alc_list_node));
  my_node->next = NULL;
  my_node->data = a_data;
  
  return my_node;
}
/**
* This is a private function, which prepares the node to be inserted.
*
* @param a_data the container to be inserted in list
*
* @return the node to be inserted, NULL if the container is too old
*
*/
This is a private function, which prepares the node to be inserted.
This is a private function which prepares the node to be inserted .
struct alc_list_node* prepare_insert(alc_rcv_container_t *a_data) {
  struct alc_list_node *my_node;
  struct timeval now;
  double container_age;
  assert(a_data != NULL);
  if(a_data->time_stamp.tv_sec == 0) {
    get_time_of_day(&(a_data->time_stamp));
    assert(a_data->time_stamp.tv_sec != 0);
  }
  else {
    get_time_of_day(&now);
    container_age =  now.tv_sec  - a_data->time_stamp.tv_sec + 
      (now.tv_usec - a_data->time_stamp.tv_usec ) / 1E6;
    assert(container_age >= 0);
    if(container_age > 3) {
      return NULL;
    } 
  }
  my_node = malloc(1 * sizeof(struct alc_list_node));
  my_node->next = NULL;
  my_node->data = a_data;
  return my_node;
}
struct alc_list_node * prepare_insert ( alc_rcv_container_t * a_data ) { struct alc_list_node * my_node ; struct timeval now ; double container_age ; assert ( a_data != NULL ) ; if ( a_data -> time_stamp . tv_sec == 0 ) { get_time_of_day ( & ( a_data -> time_stamp ) ) ; assert ( a_data -> time_stamp . tv_sec != 0 ) ; } else { get_time_of_day ( & now ) ; container_age = now . tv_sec - a_data -> time_stamp . tv_sec + ( now . tv_usec - a_data -> time_stamp . tv_usec ) / 1E6 ; assert ( container_age >= 0 ) ; if ( container_age > 3 ) { return NULL ; } } my_node = malloc ( 1 * sizeof ( struct alc_list_node ) ) ; my_node -> next = NULL ; my_node -> data = a_data ; return my_node ; }
This is a private function, which prepares the node to be inserted.
This is a private function which prepares the node to be inserted .
/* mark the timestamp first time the container is inserted */ /* check if the container is too old, in case I discard it */ /* containers older than 3 secs are discarded */