Index: /pjproject/branches/projects/uwp/aconfigure
===================================================================
--- /pjproject/branches/projects/uwp/aconfigure	(revision 5537)
+++ /pjproject/branches/projects/uwp/aconfigure	(revision 5538)
@@ -756,5 +756,4 @@
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
@@ -879,5 +878,4 @@
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
@@ -1132,13 +1130,4 @@
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
@@ -1278,5 +1267,5 @@
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
@@ -1431,5 +1420,4 @@
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
@@ -7866,7 +7854,7 @@
 fi
 
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5
-$as_echo_n "checking for SSL_library_init in -lssl... " >&6; }
-if ${ac_cv_lib_ssl_SSL_library_init+:} false; then :
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_CTX_new in -lssl" >&5
+$as_echo_n "checking for SSL_CTX_new in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_SSL_CTX_new+:} false; then :
   $as_echo_n "(cached) " >&6
 else
@@ -7882,9 +7870,9 @@
 extern "C"
 #endif
-char SSL_library_init ();
+char SSL_CTX_new ();
 int
 main ()
 {
-return SSL_library_init ();
+return SSL_CTX_new ();
   ;
   return 0;
@@ -7892,7 +7880,7 @@
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ssl_SSL_library_init=yes
-else
-  ac_cv_lib_ssl_SSL_library_init=no
+  ac_cv_lib_ssl_SSL_CTX_new=yes
+else
+  ac_cv_lib_ssl_SSL_CTX_new=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
@@ -7900,7 +7888,7 @@
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_library_init" >&5
-$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; }
-if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_CTX_new" >&5
+$as_echo "$ac_cv_lib_ssl_SSL_CTX_new" >&6; }
+if test "x$ac_cv_lib_ssl_SSL_CTX_new" = xyes; then :
   libssl_present=1 && LIBS="-lssl $LIBS"
 fi
@@ -7911,45 +7899,23 @@
 
 			# Check if SRTP should be compiled with OpenSSL
-			# support, to enable cryptos such as AES GCM
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_aes_128_gcm in -lcrypto" >&5
-$as_echo_n "checking for EVP_aes_128_gcm in -lcrypto... " >&6; }
-if ${ac_cv_lib_crypto_EVP_aes_128_gcm+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcrypto  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+			# support, to enable cryptos such as AES GCM.
+
+			# EVP_CIPHER_CTX is now opaque in OpenSSL 1.1.0, libsrtp 1.5.4 uses it as a transparent type.
+			# AC_CHECK_LIB(crypto,EVP_aes_128_gcm,[ac_ssl_has_aes_gcm=1])
+			cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char EVP_aes_128_gcm ();
+#include <openssl/evp.h>
 int
 main ()
 {
-return EVP_aes_128_gcm ();
+EVP_CIPHER_CTX ctx;EVP_aes_128_gcm();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_crypto_EVP_aes_128_gcm=yes
-else
-  ac_cv_lib_crypto_EVP_aes_128_gcm=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_aes_128_gcm" >&5
-$as_echo "$ac_cv_lib_crypto_EVP_aes_128_gcm" >&6; }
-if test "x$ac_cv_lib_crypto_EVP_aes_128_gcm" = xyes; then :
+if ac_fn_c_try_compile "$LINENO"; then :
   ac_ssl_has_aes_gcm=1
 fi
-
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 			if test "x$ac_ssl_has_aes_gcm" = "x1"; then
 				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenSSL has AES GCM support, SRTP will use OpenSSL" >&5
Index: /pjproject/branches/projects/uwp/aconfigure.ac
===================================================================
--- /pjproject/branches/projects/uwp/aconfigure.ac	(revision 5537)
+++ /pjproject/branches/projects/uwp/aconfigure.ac	(revision 5538)
@@ -1556,11 +1556,16 @@
 		AC_CHECK_HEADER(openssl/ssl.h,[openssl_h_present=1])
 		AC_CHECK_LIB(crypto,ERR_load_BIO_strings,[libcrypto_present=1 && LIBS="-lcrypto $LIBS"])
-		AC_CHECK_LIB(ssl,SSL_library_init,[libssl_present=1 && LIBS="-lssl $LIBS"])
+		AC_CHECK_LIB(ssl,SSL_CTX_new,[libssl_present=1 && LIBS="-lssl $LIBS"])
 		if test "x$openssl_h_present" = "x1" -a "x$libssl_present" = "x1" -a "x$libcrypto_present" = "x1"; then
 	        	AC_MSG_RESULT([OpenSSL library found, SSL support enabled])
 			
 			# Check if SRTP should be compiled with OpenSSL
-			# support, to enable cryptos such as AES GCM
-			AC_CHECK_LIB(crypto,EVP_aes_128_gcm,[ac_ssl_has_aes_gcm=1])
+			# support, to enable cryptos such as AES GCM.
+			
+			# EVP_CIPHER_CTX is now opaque in OpenSSL 1.1.0, libsrtp 1.5.4 uses it as a transparent type.
+			# AC_CHECK_LIB(crypto,EVP_aes_128_gcm,[ac_ssl_has_aes_gcm=1])
+			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/evp.h>]],
+							  [EVP_CIPHER_CTX ctx;EVP_aes_128_gcm();])],
+					  [ac_ssl_has_aes_gcm=1])
 			if test "x$ac_ssl_has_aes_gcm" = "x1"; then
 				AC_MSG_RESULT([OpenSSL has AES GCM support, SRTP will use OpenSSL])
Index: /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util-test/resolver_test.c
===================================================================
--- /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util-test/resolver_test.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util-test/resolver_test.c	(revision 5538)
@@ -711,4 +711,5 @@
     rc = pj_dns_parse_a_response(&pkt, &rec);
     pj_assert(rc == PJLIB_UTIL_EDNSNOANSWERREC);
+    PJ_UNUSED_ARG(rc);
 
     return 0;
@@ -920,4 +921,5 @@
     rc = pj_dns_parse_addr_response(&pkt, &rec);
     pj_assert(rc == PJLIB_UTIL_EDNSNOANSWERREC);
+    PJ_UNUSED_ARG(rc);
 
     return 0;
@@ -1469,5 +1471,5 @@
 
 
-    return 0;
+    return status;
 }
 
@@ -1839,5 +1841,5 @@
     pj_sem_wait(sem);
 
-    return 0;
+    return status;
 }
 
Index: /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/dns_server.c
===================================================================
--- /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/dns_server.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/dns_server.c	(revision 5538)
@@ -125,9 +125,5 @@
     }
 
-    if (srv->pool) {
-	pj_pool_t *pool = srv->pool;
-	srv->pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&srv->pool);
 
     return PJ_SUCCESS;
Index: /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/errno.c
===================================================================
--- /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/errno.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/errno.c	(revision 5538)
@@ -185,4 +185,4 @@
     pj_assert(status == PJ_SUCCESS);
 
-    return PJ_SUCCESS;
+    return status;
 }
Index: /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/resolver.c
===================================================================
--- /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/resolver.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/resolver.c	(revision 5538)
@@ -514,9 +514,6 @@
     }
 
-    if (resolver->pool) {
-	pj_pool_t *pool = resolver->pool;
-	resolver->pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&resolver->pool);
+
     return PJ_SUCCESS;
 }
Index: /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/srv_resolver.c
===================================================================
--- /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/srv_resolver.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjlib-util/src/pjlib-util/srv_resolver.c	(revision 5538)
@@ -653,4 +653,5 @@
     } else if (query_job->dns_state == PJ_DNS_TYPE_A) {
 	pj_bool_t is_type_a, srv_completed;
+        pj_dns_addr_record rec;
 
 	/* Clear outstanding job */
@@ -669,13 +670,24 @@
 	is_type_a = (common->type == PJ_DNS_TYPE_A);
 
+        /* Parse response */
+        if (status==PJ_SUCCESS && pkt->hdr.anscount != 0) {
+            status = pj_dns_parse_addr_response(pkt, &rec);
+            if (status!=PJ_SUCCESS) {
+                char errmsg[PJ_ERR_MSG_SIZE];
+	        
+                PJ_LOG(4,(query_job->objname, 
+		          "DNS %s record parse error for '%.*s'."
+		          " Err=%d (%s)",
+                          (is_type_a ? "A" : "AAAA"),
+		          (int)query_job->domain_part.slen,
+		          query_job->domain_part.ptr,
+		          status,
+		          pj_strerror(status,errmsg,sizeof(errmsg)).ptr));
+            }
+        }
+
 	/* Check that we really have answer */
 	if (status==PJ_SUCCESS && pkt->hdr.anscount != 0) {
 	    char addr[PJ_INET6_ADDRSTRLEN];
-	    pj_dns_addr_record rec;
-
-	    /* Parse response */
-	    status = pj_dns_parse_addr_response(pkt, &rec);
-	    if (status != PJ_SUCCESS)
-		goto on_error;
 
 	    pj_assert(rec.addr_count != 0);
Index: /pjproject/branches/projects/uwp/pjlib/include/pj/pool.h
===================================================================
--- /pjproject/branches/projects/uwp/pjlib/include/pj/pool.h	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjlib/include/pj/pool.h	(revision 5538)
@@ -391,4 +391,13 @@
 PJ_IDECL(void) pj_pool_release( pj_pool_t *pool );
 
+
+/**
+ * Release the pool back to pool factory and set the pool pointer to zero.
+ *
+ * @param ppool	    Pointer to memory pool.
+ */
+PJ_IDECL(void) pj_pool_safe_release( pj_pool_t **ppool );
+
+
 /**
  * Get pool object name.
Index: /pjproject/branches/projects/uwp/pjlib/include/pj/pool_i.h
===================================================================
--- /pjproject/branches/projects/uwp/pjlib/include/pj/pool_i.h	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjlib/include/pj/pool_i.h	(revision 5538)
@@ -93,2 +93,10 @@
 }
 
+
+PJ_IDEF(void) pj_pool_safe_release( pj_pool_t **ppool )
+{
+    pj_pool_t *pool = *ppool;
+    *ppool = NULL;
+    if (pool)
+	pj_pool_release(pool);
+}
Index: /pjproject/branches/projects/uwp/pjlib/src/pj/ssl_sock_ossl.c
===================================================================
--- /pjproject/branches/projects/uwp/pjlib/src/pj/ssl_sock_ossl.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjlib/src/pj/ssl_sock_ossl.c	(revision 5538)
@@ -46,4 +46,5 @@
  * Include OpenSSL headers 
  */
+#include <openssl/asn1.h>
 #include <openssl/bio.h>
 #include <openssl/ssl.h>
@@ -111,7 +112,19 @@
 #endif
 
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#  define OPENSSL_NO_SSL2	    /* seems to be removed in 1.1.0 */
+#  define M_ASN1_STRING_data(x)	    ASN1_STRING_get0_data(x)
+#  define M_ASN1_STRING_length(x)   ASN1_STRING_length(x)
+#else
+#  define SSL_CIPHER_get_id(c)	    (c)->id
+#  define SSL_set_session(ssl, s)   (ssl)->session = (s)
+#endif
+
+
 #ifdef _MSC_VER
 #  pragma comment( lib, "libeay32")
 #  pragma comment( lib, "ssleay32")
+#  pragma comment( lib, "crypt32")
 #endif
 
@@ -432,10 +445,11 @@
 	    c = sk_SSL_CIPHER_value(sk_cipher,i);
 	    openssl_ciphers[i].id = (pj_ssl_cipher)
-				    (pj_uint32_t)c->id & 0x00FFFFFF;
+				    (pj_uint32_t)SSL_CIPHER_get_id(c) &
+				    0x00FFFFFF;
 	    openssl_ciphers[i].name = SSL_CIPHER_get_name(c);
 	}
 	openssl_cipher_num = n;
 
-	ssl->session = SSL_SESSION_new();
+	SSL_set_session(ssl, SSL_SESSION_new());
 
 #if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x1000200fL
@@ -1014,5 +1028,6 @@
 	    c = sk_SSL_CIPHER_value(sk_cipher, j);
 	    if (ssock->param.ciphers[i] == (pj_ssl_cipher)
-					   ((pj_uint32_t)c->id & 0x00FFFFFF))
+					   ((pj_uint32_t)SSL_CIPHER_get_id(c) &
+					   0x00FFFFFF))
 	    {
 		const char *c_name;
@@ -1067,5 +1082,5 @@
     }
 
-    if( ssock->ossl_ssl->server ) {
+    if( SSL_is_server(ssock->ossl_ssl) ) {
 	ret = SSL_set1_curves(ssock->ossl_ssl, curves,
 			      ssock->param.curves_num);
@@ -1226,5 +1241,5 @@
     char buf[512];
     pj_uint8_t serial_no[64] = {0}; /* should be >= sizeof(ci->serial_no) */
-    pj_uint8_t *q;
+    const pj_uint8_t *q;
     unsigned len;
     GENERAL_NAMES *names = NULL;
@@ -1236,5 +1251,5 @@
 
     /* Get serial no */
-    q = (pj_uint8_t*) M_ASN1_STRING_data(X509_get_serialNumber(x));
+    q = (const pj_uint8_t*) M_ASN1_STRING_data(X509_get_serialNumber(x));
     len = M_ASN1_STRING_length(X509_get_serialNumber(x));
     if (len > sizeof(ci->serial_no)) 
@@ -2643,5 +2658,5 @@
 	/* Current cipher */
 	cipher = SSL_get_current_cipher(ssock->ossl_ssl);
-	info->cipher = (cipher->id & 0x00FFFFFF);
+	info->cipher = (SSL_CIPHER_get_id(cipher) & 0x00FFFFFF);
 
 	/* Remote address */
Index: /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-audiodev/legacy_dev.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-audiodev/legacy_dev.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-audiodev/legacy_dev.c	(revision 5538)
@@ -142,7 +142,5 @@
 
     if (status == PJ_SUCCESS) {
-	pj_pool_t *pool = wf->pool;
-	wf->pool = NULL;
-	pj_pool_release(pool);
+	pj_pool_safe_release(&wf->pool);
     }
 
@@ -456,8 +454,5 @@
 
     if (status == PJ_SUCCESS) {
-	pj_pool_t *pool = strm->pool;
-
-	strm->pool = NULL;
-	pj_pool_release(pool);
+	pj_pool_safe_release(&strm->pool);
     }
 
Index: /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-audiodev/null_dev.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-audiodev/null_dev.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-audiodev/null_dev.c	(revision 5538)
@@ -161,8 +161,6 @@
 {
     struct null_audio_factory *nf = (struct null_audio_factory*)f;
-    pj_pool_t *pool = nf->pool;
-
-    nf->pool = NULL;
-    pj_pool_release(pool);
+
+    pj_pool_safe_release(&nf->pool);
 
     return PJ_SUCCESS;
Index: /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-videodev/avi_dev.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-videodev/avi_dev.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-videodev/avi_dev.c	(revision 5538)
@@ -193,8 +193,6 @@
 {
     struct avi_factory *cf = (struct avi_factory*)f;
-    pj_pool_t *pool = cf->pool;
-
-    cf->pool = NULL;
-    pj_pool_release(pool);
+
+    pj_pool_safe_release(&cf->pool);
 
     return PJ_SUCCESS;
Index: /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-videodev/colorbar_dev.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-videodev/colorbar_dev.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/pjmedia-videodev/colorbar_dev.c	(revision 5538)
@@ -253,8 +253,6 @@
 {
     struct cbar_factory *cf = (struct cbar_factory*)f;
-    pj_pool_t *pool = cf->pool;
-
-    cf->pool = NULL;
-    pj_pool_release(pool);
+
+    pj_pool_safe_release(&cf->pool);
 
     return PJ_SUCCESS;
Index: /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/clock_thread.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/clock_thread.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/clock_thread.c	(revision 5538)
@@ -416,11 +416,8 @@
     }
 
-    if (clock->pool) {
-	pj_pool_t *pool = clock->pool;
-	clock->pool = NULL;
-	pj_pool_release(pool);
-    }
-    return PJ_SUCCESS;
-}
-
-
+    pj_pool_safe_release(&clock->pool);
+
+    return PJ_SUCCESS;
+}
+
+
Index: /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/stream.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/stream.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/stream.c	(revision 5538)
@@ -2572,9 +2572,6 @@
 #endif
 
-    if (stream->own_pool) {
-	pj_pool_t *pool = stream->own_pool;
-	stream->own_pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&stream->own_pool);
+
     return PJ_SUCCESS;
 }
Index: /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/transport_ice.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/transport_ice.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/transport_ice.c	(revision 5538)
@@ -1879,9 +1879,5 @@
     }
 
-    if (tp_ice->pool) {
-	pj_pool_t *pool = tp_ice->pool;
-	tp_ice->pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&tp_ice->pool);
 
     return PJ_SUCCESS;
Index: /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/vid_stream.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/vid_stream.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/pjmedia/vid_stream.c	(revision 5538)
@@ -1805,9 +1805,5 @@
 #endif
 
-    if (stream->own_pool) {
-	pj_pool_t *pool = stream->own_pool;
-	stream->own_pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&stream->own_pool);
 
     return PJ_SUCCESS;
Index: /pjproject/branches/projects/uwp/pjmedia/src/test/mips_test.c
===================================================================
--- /pjproject/branches/projects/uwp/pjmedia/src/test/mips_test.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjmedia/src/test/mips_test.c	(revision 5538)
@@ -716,5 +716,5 @@
     }
 
-    return PJ_SUCCESS;
+    return status;
 }
 
@@ -1030,5 +1030,5 @@
     }
 
-    return PJ_SUCCESS;
+    return status;
 }
 
@@ -1203,5 +1203,5 @@
     }
 
-    return PJ_SUCCESS;
+    return status;
 }
 
@@ -2094,5 +2094,5 @@
     }
 
-    return PJ_SUCCESS;
+    return status;
 }
 
@@ -2122,5 +2122,5 @@
     }
 
-    return PJ_SUCCESS;
+    return status;
 }
 
@@ -2366,4 +2366,5 @@
 	}
     }
+    PJ_UNUSED_ARG(status);
     pj_get_timestamp(&t1);
 
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/concur_test.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/concur_test.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/concur_test.c	(revision 5538)
@@ -289,4 +289,5 @@
 	pj_assert(status == PJ_SUCCESS);
     }
+    PJ_UNUSED_ARG(status);
 
     /* Test 1: Main thread calls destroy while callback is processing response */
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/ice_test.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/ice_test.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/ice_test.c	(revision 5538)
@@ -403,9 +403,5 @@
     }
 
-    if (sess->pool) {
-	pj_pool_t *pool = sess->pool;
-	sess->pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&sess->pool);
 }
 
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/server.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/server.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/server.c	(revision 5538)
@@ -255,9 +255,5 @@
     }
 
-    if (test_srv->pool) {
-	pj_pool_t *pool = test_srv->pool;
-	test_srv->pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&test_srv->pool);
 }
 
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/stun.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/stun.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath-test/stun.c	(revision 5538)
@@ -319,4 +319,5 @@
 				&msg, NULL, &res);
     pj_assert(status != PJ_SUCCESS);
+    PJ_UNUSED_ARG(status);
     pj_assert(res != NULL);
 
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath/errno.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath/errno.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath/errno.c	(revision 5538)
@@ -185,5 +185,5 @@
     pj_assert(status == PJ_SUCCESS);
 
-    return PJ_SUCCESS;
+    return status;
 }
 
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath/ice_session.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath/ice_session.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath/ice_session.c	(revision 5538)
@@ -462,9 +462,6 @@
     pj_ice_sess *ice = (pj_ice_sess*) obj;
 
-    if (ice->pool) {
-	pj_pool_t *pool = ice->pool;
-	ice->pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&ice->pool);
+
     LOG4((THIS_FILE, "ICE session %p destroyed", ice));
 }
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath/stun_sock.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath/stun_sock.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath/stun_sock.c	(revision 5538)
@@ -475,9 +475,5 @@
     */
 
-    if (stun_sock->pool) {
-	pj_pool_t *pool = stun_sock->pool;
-	stun_sock->pool = NULL;
-	pj_pool_release(pool);
-    }
+    pj_pool_safe_release(&stun_sock->pool);
 
     TRACE_(("", "STUN sock %p destroyed", stun_sock));
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath/turn_session.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath/turn_session.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath/turn_session.c	(revision 5538)
@@ -329,10 +329,6 @@
     /* Destroy pool */
     if (sess->pool) {
-	pj_pool_t *pool = sess->pool;
-
 	PJ_LOG(4,(sess->obj_name, "TURN client session destroyed"));
-
-	sess->pool = NULL;
-	pj_pool_release(pool);
+	pj_pool_safe_release(&sess->pool);
     }
 }
Index: /pjproject/branches/projects/uwp/pjnath/src/pjnath/turn_sock.c
===================================================================
--- /pjproject/branches/projects/uwp/pjnath/src/pjnath/turn_sock.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjnath/src/pjnath/turn_sock.c	(revision 5538)
@@ -218,8 +218,6 @@
 
     if (turn_sock->pool) {
-	pj_pool_t *pool = turn_sock->pool;
 	PJ_LOG(4,(turn_sock->obj_name, "TURN socket destroyed"));
-	turn_sock->pool = NULL;
-	pj_pool_release(pool);
+	pj_pool_safe_release(&turn_sock->pool);
     }
 }
Index: /pjproject/branches/projects/uwp/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip-apps/src/pjsua/pjsua_app.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip-apps/src/pjsua/pjsua_app.c	(revision 5538)
@@ -2011,8 +2011,5 @@
     }
 
-    if (app_config.pool) {
-	pj_pool_release(app_config.pool);
-	app_config.pool = NULL;
-    }
+    pj_pool_safe_release(&app_config.pool);
 
     status = pjsua_destroy();
Index: /pjproject/branches/projects/uwp/pjsip-apps/src/pjsua/pjsua_app_cli.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip-apps/src/pjsua/pjsua_app_cli.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip-apps/src/pjsua/pjsua_app_cli.c	(revision 5538)
@@ -208,8 +208,4 @@
     if (app_config.cli_cfg.cli_fe & CLI_FE_TELNET) {
 	pj_cli_telnet_cfg *fe_cfg = &app_config.cli_cfg.telnet_cfg;
-	pj_pool_t *pool;
-
-	pool = pj_pool_create(cfg->pf, "cli_cp", 128, 128, NULL);
-	pj_assert(pool);
 
 	status = pj_cli_telnet_create(cli, fe_cfg, &telnet_front_end);
Index: /pjproject/branches/projects/uwp/pjsip-apps/src/samples/aectest.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip-apps/src/samples/aectest.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip-apps/src/samples/aectest.c	(revision 5538)
@@ -301,4 +301,5 @@
 	puts("ENTER to quit");
 	dummy = fgets(s, sizeof(s), stdin);
+	PJ_UNUSED_ARG(dummy);
     }
 
Index: /pjproject/branches/projects/uwp/pjsip-apps/src/samples/auddemo.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip-apps/src/samples/auddemo.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip-apps/src/samples/auddemo.c	(revision 5538)
@@ -297,4 +297,5 @@
     PJ_LOG(3,(THIS_FILE, "Recording started, press ENTER to stop"));
     dummy = fgets(line, sizeof(line), stdin);
+    PJ_UNUSED_ARG(dummy);
 
 on_return:
@@ -364,4 +365,5 @@
     PJ_LOG(3,(THIS_FILE, "Playback started, press ENTER to stop"));
     dummy = fgets(line, sizeof(line), stdin);
+    PJ_UNUSED_ARG(dummy);
 
 on_return:
Index: /pjproject/branches/projects/uwp/pjsip-apps/src/samples/aviplay.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip-apps/src/samples/aviplay.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip-apps/src/samples/aviplay.c	(revision 5538)
@@ -468,5 +468,5 @@
     	puts("Error: filename required");
 	puts(desc);
-	return 1;
+	return 110;
     }
 
@@ -474,5 +474,5 @@
     /* Must init PJLIB first: */
     status = pj_init();
-    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 120);
 
     /* Must create a pool factory before we can allocate any memory. */
@@ -493,9 +493,12 @@
     
     status = pjmedia_vid_dev_subsys_init(&cp.factory);
-    if (status != PJ_SUCCESS)
+    if (status != PJ_SUCCESS) {
+	rc = 130;
         goto on_return;
+    }
     
     status = pjmedia_aud_subsys_init(&cp.factory);
     if (status != PJ_SUCCESS) {
+	rc = 140;
         goto on_return;
     }
@@ -503,12 +506,16 @@
 #if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
     status = pjmedia_codec_openh264_vid_init(NULL, &cp.factory);
-    if (status != PJ_SUCCESS)
+    if (status != PJ_SUCCESS) {
+	rc = 150;
 	goto on_return;
+    }
 #endif
 
 #if PJMEDIA_HAS_FFMPEG_VID_CODEC
     status = pjmedia_codec_ffmpeg_vid_init(NULL, &cp.factory);
-    if (status != PJ_SUCCESS)
+    if (status != PJ_SUCCESS) {
+	rc = 160;
 	goto on_return;    
+    }
 #endif
 
@@ -549,5 +556,5 @@
 
     /* Done. */
-    return 0;
+    return rc;
 }
 
Index: /pjproject/branches/projects/uwp/pjsip-apps/src/samples/pjsip-perf.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip-apps/src/samples/pjsip-perf.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip-apps/src/samples/pjsip-perf.c	(revision 5538)
@@ -1476,4 +1476,5 @@
 	    status = submit_job();
 	}
+	PJ_UNUSED_ARG(status);
 
 	++app.client.job_submitted;
Index: /pjproject/branches/projects/uwp/pjsip-apps/src/samples/siprtp.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip-apps/src/samples/siprtp.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip-apps/src/samples/siprtp.c	(revision 5538)
@@ -1398,5 +1398,4 @@
 {
     struct call *call;
-    pj_pool_t *pool;
     struct media_stream *audio;
     const pjmedia_sdp_session *local_sdp, *remote_sdp;
@@ -1405,5 +1404,4 @@
 
     call = inv->mod_data[mod_siprtp.id];
-    pool = inv->dlg->pool;
     audio = &call->media[0];
 
Index: /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_loop.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_loop.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_loop.c	(revision 5538)
@@ -191,4 +191,5 @@
 						 &recv_pkt->rdata);
 	pj_assert(size_eaten == recv_pkt->rdata.pkt_info.len);
+	PJ_UNUSED_ARG(size_eaten);
 
 	pjsip_endpt_release_pool(loop->base.endpt, 
@@ -337,4 +338,5 @@
 	    /* Must "eat" all the packets. */
 	    pj_assert(size_eaten == node->rdata.pkt_info.len);
+	    PJ_UNUSED_ARG(size_eaten);
 
 	    /* Done. */
Index: /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_tcp.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_tcp.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_tcp.c	(revision 5538)
@@ -567,10 +567,6 @@
 
     if (listener->factory.pool) {
-	pj_pool_t *pool = listener->factory.pool;
-
 	PJ_LOG(4,(listener->factory.obj_name,  "SIP TCP transport destroyed"));
-
-	listener->factory.pool = NULL;
-	pj_pool_release(pool);
+	pj_pool_safe_release(&listener->factory.pool);
     }
 }
Index: /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_tls.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_tls.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_transport_tls.c	(revision 5538)
@@ -604,10 +604,6 @@
 
     if (listener->factory.pool) {
-	pj_pool_t *pool = listener->factory.pool;
-
 	PJ_LOG(4,(listener->factory.obj_name,  "SIP TLS transport destroyed"));
-
-	listener->factory.pool = NULL;
-	pj_pool_release(pool);
+	pj_pool_safe_release(&listener->factory.pool);
     }
 }
Index: /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_acc.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 5538)
@@ -2600,4 +2600,5 @@
 				uri, acc->cfg.reg_uri.slen+10);
 	    pj_assert(d > 0);
+	    PJ_UNUSED_ARG(d);
 
 	    h = pjsip_authorization_hdr_create(tdata->pool);
Index: /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_call.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_call.c	(revision 5538)
@@ -3317,4 +3317,5 @@
 	/* Verify that media must be active. */
 	pj_assert(loc_m->desc.port && rem_m->desc.port);
+	PJ_UNUSED_ARG(loc_m);
 
 	/* Count the formats in the answer. */
Index: /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_media.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_media.c	(revision 5538)
@@ -2252,4 +2252,6 @@
     if (call->inv && call->inv->neg)
 	sdp_neg_state = pjmedia_sdp_neg_get_state(call->inv->neg);
+
+    PJ_UNUSED_ARG(sdp_neg_state);
 
     /* Get one address to use in the origin field */
Index: /pjproject/branches/projects/uwp/pjsip/src/test/inv_offer_answer_test.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/test/inv_offer_answer_test.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/test/inv_offer_answer_test.c	(revision 5538)
@@ -185,4 +185,5 @@
     status = pjmedia_sdp_parse(pool, dup.ptr, dup.slen, &sdp);
     pj_assert(status == PJ_SUCCESS);
+    PJ_UNUSED_ARG(status);
 
     return sdp;
@@ -336,5 +337,5 @@
 	pj_assert(status == PJ_SUCCESS);
 
-	return PJ_TRUE;
+	return (status == PJ_SUCCESS);
     }
 
@@ -393,4 +394,5 @@
 	break;
     }
+    PJ_UNUSED_ARG(status);
 }
 
@@ -677,4 +679,5 @@
 	status = pjsip_udp_transport_start(endpt, &addr, NULL, 1, &tp);
 	pj_assert(status == PJ_SUCCESS);
+	PJ_UNUSED_ARG(status);
     }
 
Index: /pjproject/branches/projects/uwp/pjsip/src/test/regc_test.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/test/regc_test.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/test/regc_test.c	(revision 5538)
@@ -205,5 +205,5 @@
     pj_assert(status == PJ_SUCCESS);
 
-    return PJ_TRUE;
+    return (status == PJ_SUCCESS);
 }
 
@@ -243,4 +243,5 @@
     status = pjsip_regc_get_info(param->regc, &info);
     pj_assert(status == PJ_SUCCESS);
+    PJ_UNUSED_ARG(status);
 
     client->error = (param->status != PJ_SUCCESS);
Index: /pjproject/branches/projects/uwp/pjsip/src/test/tsx_uac_test.c
===================================================================
--- /pjproject/branches/projects/uwp/pjsip/src/test/tsx_uac_test.c	(revision 5537)
+++ /pjproject/branches/projects/uwp/pjsip/src/test/tsx_uac_test.c	(revision 5538)
@@ -778,6 +778,5 @@
 	pjsip_endpt_schedule_timer(endpt, &timer.entry, &delay);
 
-	return PJ_TRUE;
-
+	return (status == PJ_SUCCESS);
 
     } else
@@ -851,5 +850,5 @@
 	 */
 	pjsip_method *method;
-	pj_status_t status;
+	pj_status_t status = PJ_SUCCESS;
 
 	method = &rdata->msg_info.msg->line.req.method;
@@ -934,5 +933,5 @@
 	}
 
-	return PJ_TRUE;
+	return (status == PJ_SUCCESS);
 
     }
