apps/dtnrespond/dtnrespond.c
changeset 76 aeabfd54d3b6
parent 71 fdb6e00dacc9
equal deleted inserted replaced
75:d647d52028bc 76:aeabfd54d3b6
   796         fprintf (stderr, "Error decoding number of fragments\n");
   796         fprintf (stderr, "Error decoding number of fragments\n");
   797         return -1;
   797         return -1;
   798     }
   798     }
   799     i += f_decoding_len;
   799     i += f_decoding_len;
   800 
   800 
       
   801     if ( bpq->fragments.num_frag_returned > 0 ) {
       
   802     	bpq->fragments.frag_offsets = (u_int*) malloc ( sizeof(u_int) * bpq->fragments.num_frag_returned );
       
   803     	bpq->fragments.frag_lenghts = (u_int*) malloc ( sizeof(u_int) * bpq->fragments.num_frag_returned );
       
   804     } else {
       
   805     	bpq->fragments.frag_offsets = NULL;
       
   806     	bpq->fragments.frag_lenghts = NULL;
       
   807     }
       
   808 
   801     for (j=0; i<buf_len && j<(int)bpq->fragments.num_frag_returned; ++j) {
   809     for (j=0; i<buf_len && j<(int)bpq->fragments.num_frag_returned; ++j) {
   802 
   810 
   803         // fragment offsets     SDNV
   811         // fragment offsets     SDNV
   804         if ( (decoding_len = sdnv_decode (&(buf[i]),
   812         if ( (decoding_len = sdnv_decode (&(buf[i]),
   805         								  buf_len - i,
   813         								  buf_len - i,
  1040             }
  1048             }
  1041         }
  1049         }
  1042         dtn_free_payload(&payload);
  1050         dtn_free_payload(&payload);
  1043     }
  1051     }
  1044 
  1052 
       
  1053     // if fragment memory was allocated
       
  1054     // free it now
       
  1055     if ( bpq_block_data.fragments.frag_offsets != NULL ){
       
  1056     	free(bpq_block_data.fragments.frag_offsets);
       
  1057     	bpq_block_data.fragments.frag_offsets = NULL;
       
  1058     }
       
  1059 
       
  1060     if ( bpq_block_data.fragments.frag_lenghts != NULL ){
       
  1061     	free(bpq_block_data.fragments.frag_lenghts);
       
  1062     	bpq_block_data.fragments.frag_lenghts = NULL;
       
  1063     }
       
  1064 
  1045     return ret;
  1065     return ret;
  1046 }
  1066 }
  1047 
  1067 
  1048 /*******************************************************************************
  1068 /*******************************************************************************
  1049 * main:
  1069 * main: