On 2010-03-19 13:13, Peter Stuge wrote:
> libssh2_at_git.stuge.se wrote:
>
>> +++ b/src/global.c
>> @@ -37,12 +37,12 @@
>>
>> #include "libssh2_priv.h"
>>
>> -int libssh2_initialized = 0;
>> -int libssh2_init_flags = 0;
>> +static int _libssh2_initialized = 0;
>> +static int _libssh2_init_flags = 0;
>>
>> LIBSSH2_API int libssh2_init(int flags)
>> {
>> - if (!(flags& LIBSSH2_INIT_NO_CRYPTO_INIT)) {
>> + if (libssh2_initialized == 0&& !(flags& LIBSSH2_INIT_NO_CRYPTO_INIT)) {
>> libssh2_crypto_init();
>> }
>>
>> @@ -57,11 +57,18 @@ LIBSSH2_API void libssh2_exit()
>> if (libssh2_initialized == 0)
>> return;
>>
>> + libssh2_initialized--;
>>
> Shouldn't these two uses of the variable be changed? Maybe there are
> other places too?
>
>
Making those to static would require a new function to check the value
of libssh2_initialized (used in session.c to preserve the methode if
doing init in session_init.
It's a question on how to handle global variables, should they be
handled only by calls to functions in global.c? Or is it OK to check and
set the variable direct in other parts of libssh2.
BTW, is _ the libssh2 standard for static variables? I trying to
understand the code-standard.
> //Peter
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
>
>
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-03-19