]> sjero.net Git - linphone/commitdiff
Remove function static variables
authorYann Diorcet <yann.diorcet@belledonne-communications.com>
Tue, 30 Oct 2012 12:48:06 +0000 (13:48 +0100)
committerYann Diorcet <yann.diorcet@belledonne-communications.com>
Tue, 30 Oct 2012 12:48:06 +0000 (13:48 +0100)
coreapi/linphonecore.c
coreapi/private.h

index 503a71c03b290921711d553e7ec256cad792a6b9..b25523df19db0fccd1a4a1d5fcdda5c6fce3694c 100644 (file)
@@ -1192,6 +1192,9 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
        sal_set_user_pointer(lc->sal,lc);
        sal_set_callbacks(lc->sal,&linphone_sal_callbacks);
 
+        lc->network_last_check = 0;
+        lc->network_last_status = FALSE;
+
        sip_setup_register_all();
        sound_config_read(lc);
        net_config_read(lc);
@@ -1803,24 +1806,22 @@ void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val){
 
 
 static void monitor_network_state(LinphoneCore *lc, time_t curtime){
-       static time_t last_check=0;
-       static bool_t last_status=FALSE;
        char result[LINPHONE_IPADDR_SIZE];
-       bool_t new_status=last_status;
+       bool_t new_status=lc->network_last_status;
 
        /* only do the network up checking every five seconds */
-       if (last_check==0 || (curtime-last_check)>=5){
+       if (lc->network_last_check==0 || (curtime-lc->network_last_check)>=5){
                linphone_core_get_local_ip_for(lc->sip_conf.ipv6_enabled ? AF_INET6 : AF_INET,NULL,result);
                if (strcmp(result,"::1")!=0 && strcmp(result,"127.0.0.1")!=0){
                        new_status=TRUE;
                }else new_status=FALSE;
-               last_check=curtime;
-               if (new_status!=last_status) {
+               lc->network_last_check=curtime;
+               if (new_status!=lc->network_last_status) {
                        if (new_status){
                                ms_message("New local ip address is %s",result);
                        }
                        set_network_reachable(lc,new_status, curtime);
-                       last_status=new_status;
+                       lc->network_last_status=new_status;
                }
        }
 }
index 07fd1c689189766bd999982326ba06b9742de5e6..e9165a501404e3f5dd4acb1dd994e010d52108f3 100644 (file)
@@ -556,6 +556,9 @@ struct _LinphoneCore
        bool_t network_reachable;
        bool_t use_preview_window;
        
+        time_t network_last_check;
+        bool_t network_last_status;
+
        bool_t ringstream_autorelease;
        bool_t pad[3];
        int device_rotation;