> On Sep 1, 2015, at 4:46 AM, Peter Stuge <peter_at_stuge.se> wrote:
>
> Engstrom, John wrote:
>> Yeah, technically the line "LIBSSH2_SESSION **session;" is actually
>> "LIBSSH2_SESSION **session)" as in it's the last parameter to a function.
>> The calling code passes in the address of a LIBSSH2_SESSION *.
>
> Yes, you dereference a double pointer, but which address does it pass?
>
> If all you have is a pointer to a pointer then you have no actual
> memory where a pointer can be stored. Why are you using a double
> pointer? It seems to be getting you into trouble.
>
>
> //Peter
Peter, the calling code has an auto variable LIBSSH2_SESSION *session . We use the ssh session in other routines - for example where we call libssh2_userauth_list(). Because we are passing the LIBSSH2_SESSION *session into a routine that is responsible for creating the session pointer we pass in the pointer pointer so it can modify the pointer in the caller. Make sense?
John Engstrom
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2015-09-01