src/stored/cloud_parts.c
bool diff_lists(ilist *source, ilist *dest, ilist *diff)
{
   if (source && dest && diff) {
      /* Using indexed list forces us to treat it differently (foreach not working b.e.) */
      int max_size = source->last_index();
      if (dest->last_index() > source->last_index()) {
         max_size = dest->last_index();
      }
      for(int index=0; index<=max_size; index++ ) {
         cloud_part *p1 = (cloud_part *)source->get(index);
         cloud_part *p2 = (cloud_part *)dest->get(index);
         if (!p1) {
            if (p2) diff->put(index, p1);
         } else if (!p2) {
            if (p1) diff->put(index, p1);
         } else if (*p1 != *p2) {
            diff->put(index, p1);
         }
      }
      return true;
   }
   return false;
}
/* cloud_parts present in source but not in dest are appended to diff.
 * there's no cloud_part copy made.
 * Diff only holds references and shoudn't own them */
cloud_parts present in source but not in dest are appended to diff.
there's no cloud_part copy made.
Diff only holds references and shoudn't own them
cloud_parts present in source but not in dest are appended to diff . there ' s no cloud_part copy made . Diff only holds references and shoudn ' t own them
bool diff_lists(ilist *source, ilist *dest, ilist *diff)
{
   if (source && dest && diff) {
      int max_size = source->last_index();
      if (dest->last_index() > source->last_index()) {
         max_size = dest->last_index();
      }
      for(int index=0; index<=max_size; index++ ) {
         cloud_part *p1 = (cloud_part *)source->get(index);
         cloud_part *p2 = (cloud_part *)dest->get(index);
         if (!p1) {
            if (p2) diff->put(index, p1);
         } else if (!p2) {
            if (p1) diff->put(index, p1);
         } else if (*p1 != *p2) {
            diff->put(index, p1);
         }
      }
      return true;
   }
   return false;
}
bool diff_lists ( ilist * source , ilist * dest , ilist * diff ) { if ( source && dest && diff ) { int max_size = source -> last_index ( ) ; if ( dest -> last_index ( ) > source -> last_index ( ) ) { max_size = dest -> last_index ( ) ; } for ( int index = 0 ; index <= max_size ; index ++ ) { cloud_part * p1 = ( cloud_part * ) source -> get ( index ) ; cloud_part * p2 = ( cloud_part * ) dest -> get ( index ) ; if ( ! p1 ) { if ( p2 ) diff -> put ( index , p1 ) ; } else if ( ! p2 ) { if ( p1 ) diff -> put ( index , p1 ) ; } else if ( * p1 != * p2 ) { diff -> put ( index , p1 ) ; } } return true ; } return false ; }
cloud_parts present in source but not in dest are appended to diff.
cloud_parts present in source but not in dest are appended to diff .
/* Using indexed list forces us to treat it differently (foreach not working b.e.) */