![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: rtp.cpp
- Revision:
- 87:679ee0d594a9
- Parent:
- 85:b6f2dc1d0f4f
- Child:
- 89:0fe315117b00
--- a/rtp.cpp Mon Jan 05 12:43:12 2015 +0000 +++ b/rtp.cpp Tue Jan 06 16:37:03 2015 +0000 @@ -64,22 +64,49 @@ RTP::RTP( int ext ){ rtp_header = new RTP_Header( ext ); + + if( rtp_header == NULL ) + { + memory_is_over = true; + if( debug_rtp == true ) send_msg("RTP_HEADER allocation failed"); + } + else + { + rtp_header_new_counter++; + } + rtp_body = new RTP_Body(); - rtp_new_counter++; + if( rtp_body == NULL ) + { + memory_is_over = true; + if( debug_rtp == true ) send_msg("RTP_BODY allocation failed"); + } + else + { + rtp_body_new_counter++; + } } RTP::~RTP(){ - if( rtp_header ) delete( rtp_header ); - if( rtp_body ) delete( rtp_body ); - rtp_delete_counter++; + if( rtp_header != NULL) + { + delete( rtp_header ); + rtp_header_delete_counter++; + } + if( rtp_body != NULL ) + { + delete( rtp_body ); + rtp_body_delete_counter++; + } } char * RTP::build_eth_package( char * buffer ){ - rtp_header->build_header( this->pkg ); - rtp_body->build_body( this->pkg + __RTP_HEADER_OFFSET__, buffer ); + if( rtp_header != NULL ) rtp_header->build_header( this->pkg ); + if( rtp_body != NULL ) rtp_body->build_body( this->pkg + __RTP_HEADER_OFFSET__, buffer ); return( this->pkg ); } size_t RTP::header_size( void ){ - return rtp_header->size(); + //if( rtp_header != NULL ) return rtp_header->size(); + return ( rtp_header != NULL ) ? rtp_header->size() : 0; } \ No newline at end of file