aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2020-04-03 17:51:53 +0200
committerAndreas Schneider <asn@cryptomilk.org>2020-04-09 11:25:49 +0200
commite3e52394c11e7b9bafa3086e7be937388540daeb (patch)
treed89bd7bd5d5836a4625f1190916e20f13ce8e1f8 /src
parentb36272eac1b36982598c10de7af0a501582de07a (diff)
downloadlibssh-e3e52394c11e7b9bafa3086e7be937388540daeb.tar.gz
libssh-e3e52394c11e7b9bafa3086e7be937388540daeb.tar.xz
libssh-e3e52394c11e7b9bafa3086e7be937388540daeb.zip
init: Clarify the need to call ssh_{init, finalize}()
When libssh is statically linked, it is necessary to explicitly call ssh_init() before calling any other provided API. It is also necessary to call ssh_finalize() before exiting to free allocated resources. Fixes T222 Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src')
-rw-r--r--src/init.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/init.c b/src/init.c
index 9e70bf65..edecb95e 100644
--- a/src/init.c
+++ b/src/init.c
@@ -135,14 +135,20 @@ void libssh_constructor(void)
/**
* @brief Initialize global cryptographic data structures.
*
- * Since version 0.8.0, it is not necessary to call this function on systems
- * which are fully supported with regards to threading (that is, system with
- * pthreads available).
+ * Since version 0.8.0, when libssh is dynamically linked, it is not necessary
+ * to call this function on systems which are fully supported with regards to
+ * threading (that is, system with pthreads available).
+ *
+ * If libssh is statically linked, it is necessary to explicitly call ssh_init()
+ * before calling any other provided API, and it is necessary to explicitly call
+ * ssh_finalize() to free the allocated resources before exiting.
*
* If the library is already initialized, increments the _ssh_initialized
* counter and return the error code cached in _ssh_init_ret.
*
* @returns SSH_OK on success, SSH_ERROR if an error occurred.
+ *
+ * @see ssh_finalize()
*/
int ssh_init(void) {
return _ssh_init(0);
@@ -202,8 +208,13 @@ void libssh_destructor(void)
/**
* @brief Finalize and cleanup all libssh and cryptographic data structures.
*
- * Since version 0.8.0, it is not necessary to call this function, since it is
- * automatically called when the library is unloaded.
+ * Since version 0.8.0, when libssh is dynamically linked, it is not necessary
+ * to call this function, since it is automatically called when the library is
+ * unloaded.
+ *
+ * If libssh is statically linked, it is necessary to explicitly call ssh_init()
+ * before calling any other provided API, and it is necessary to explicitly call
+ * ssh_finalize() to free the allocated resources before exiting.
*
* If ssh_init() is called explicitly, then ssh_finalize() must be called
* explicitly.
@@ -211,9 +222,9 @@ void libssh_destructor(void)
* When called, decrements the counter _ssh_initialized. If the counter reaches
* zero, then the libssh and cryptographic data structures are cleaned up.
*
- * @returns 0 on succes, -1 if an error occured.
+ * @returns 0 on success, -1 if an error occurred.
*
- @returns 0 otherwise
+ * @see ssh_init()
*/
int ssh_finalize(void) {
return _ssh_finalize(0);