Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
87:679ee0d594a9
Parent:
85:b6f2dc1d0f4f
Child:
89:0fe315117b00
--- a/call_box.cpp	Mon Jan 05 12:43:12 2015 +0000
+++ b/call_box.cpp	Tue Jan 06 16:37:03 2015 +0000
@@ -11,6 +11,8 @@
     status = cb_idle;
     sip = new Sip( ext, port );
     
+    if( sip == NULL ) memory_is_over = true;
+    
     next_aging_type = __CYCLES__;
     seconds.start();
     invite_response = true;
@@ -66,6 +68,10 @@
 void Call_Box::registry( void ){
     if( this->sip == NULL ){
         this->sip = new Sip( ext, port );
+        if( sip == NULL ){
+            memory_is_over = true;
+            return;
+        }
     
         if( sip->registry() > 0x00 ) reset_elapsed_time();
         if( debug_aging ) debug_msg( "%d Registered - ( %f )", ext, __TIMEOUT__ - t.read() );
@@ -81,7 +87,10 @@
 void Call_Box::unregistry( void ){
     if( this->sip == NULL ){ 
         this->sip = new Sip( ext, port );
-    
+        if( sip == NULL ){
+            memory_is_over = true;
+            return;    
+        }
         sip->send_unregistry_pkg();
     
         delete( sip );
@@ -98,10 +107,15 @@
     if( this->sip == NULL ){
         this->sip = new Sip( ext, port );
         
-        call = sip->invite();
-        
-        delete( sip );
-        this->sip = NULL;
+        if( sip != NULL ){
+            memory_is_over = true;
+            return( NULL );
+        }else{
+            call = sip->invite();
+            
+            delete( sip );
+            this->sip = NULL;
+        }
     }else{   
         call = sip->invite();
     }
@@ -120,10 +134,17 @@
     if( this->sip == NULL ){
         if( status == cb_on_call || status == cb_idle ){
             this->sip = new Sip( ext, port );
-            int out_read = sip->listen_SIP_server();
-            delete( sip );
-            this->sip = NULL;
-            return( out_read );
+            
+            if( sip == NULL ){
+                memory_is_over = true;
+                return( -1 );
+            }else{
+                int out_read = sip->listen_SIP_server();
+                
+                delete( sip );
+                this->sip = NULL;
+                return( out_read );
+            }
         }else return( 0 );
     }else{
         if( status == cb_on_call || status == cb_idle ){
@@ -150,10 +171,16 @@
     if( this->sip == NULL ){
         this->sip = new Sip( ext, port );
         
-        sip->send_bye();
+        if( sip == NULL ){
+            memory_is_over = true;
+            return;
+        }else{
         
-        delete( sip );
-        sip = NULL;
+            sip->send_bye();
+            
+            delete( sip );
+            sip = NULL;
+        }
     }else{
         sip->send_bye();
     }
@@ -163,6 +190,8 @@
     if( this->sip != NULL ) delete( this->sip );
     
     this->sip = new Sip( ext, port );
+    
+    if( sip == NULL ) memory_is_over = true;
 }
 
 void Call_Box::set_sip_status( int status ){