doc/man3: use the documented coding style in the example code
[openssl.git] / doc / man3 / CRYPTO_THREAD_run_once.pod
index b256a186370e06ef65a37cf892b3b302cd557eb6..9a4df1992c0e7b3cfbd835b6bd22bca8a28d3926 100644 (file)
@@ -100,42 +100,42 @@ crypto.h where use of CRYPTO_THREAD_* types and functions is required.
 
 This example safely initializes and uses a lock.
 
 #ifdef _WIN32
 # include <windows.h>
 #endif
 #include <openssl/crypto.h>
-
 static CRYPTO_ONCE once = CRYPTO_ONCE_STATIC_INIT;
 static CRYPTO_RWLOCK *lock;
-
 static void myinit(void)
 {
-      lock = CRYPTO_THREAD_lock_new();
 }
-
 static int mylock(void)
 {
-      if (!CRYPTO_THREAD_run_once(&once, void init) || lock == NULL)
-          return 0;
-      return CRYPTO_THREAD_write_lock(lock);
 }
-
 static int myunlock(void)
 {
-      return CRYPTO_THREAD_unlock(lock);
 }
-
 int serialized(void)
 {
-      int ret = 0;
-
-      if (mylock()) {
-          /* Your code here, do not return without releasing the lock! */
-          ret = ... ;
-      }
-      myunlock();
-      return ret;
 }
+ #ifdef _WIN32
+ # include <windows.h>
+ #endif
+ #include <openssl/crypto.h>
+
+ static CRYPTO_ONCE once = CRYPTO_ONCE_STATIC_INIT;
+ static CRYPTO_RWLOCK *lock;
+
+ static void myinit(void)
+ {
+     lock = CRYPTO_THREAD_lock_new();
+ }
+
+ static int mylock(void)
+ {
+     if (!CRYPTO_THREAD_run_once(&once, void init) || lock == NULL)
+         return 0;
+     return CRYPTO_THREAD_write_lock(lock);
+ }
+
+ static int myunlock(void)
+ {
+     return CRYPTO_THREAD_unlock(lock);
+ }
+
+ int serialized(void)
+ {
+     int ret = 0;
+
+     if (mylock()) {
+         /* Your code here, do not return without releasing the lock! */
+         ret = ... ;
+     }
+     myunlock();
+     return ret;
+ }
 
 Finalization of locks is an advanced topic, not covered in this example.
 This can only be done at process exit or when a dynamically loaded library is
@@ -149,9 +149,9 @@ You can find out if OpenSSL was configured with thread support:
 
  #include <openssl/opensslconf.h>
  #if defined(OPENSSL_THREADS)
-   // thread support enabled
+     /* thread support enabled */
  #else
-   // no thread support
+     /* no thread support */
  #endif
 
 =head1 SEE ALSO