Subject: Re: RE : About allocation/desallocation

Re: RE : About allocation/desallocation

From: Daniel Stenberg <>
Date: Sun, 29 Mar 2009 11:19:06 +0200 (CEST)

On Sat, 28 Mar 2009, Jean-Louis CHARTON wrote:

> Now, maybe you better understand why my code allocated a 7 bytes buffer to
> store the method: just because the method is freed later in
> userauth_hostbased_fromfile / userauth_publickey_fromfile ...

Yes I do, and I must admit I didn't see the whole picture when I asked you
about that 7 bytes alloc. I can't claim I'm very familiar with the whole
libssh2 code base yet.

> Maybe a better solution could be to always assume/impose that methods be
> constant static storage everywhere in libssh2. In that case, there would be
> no need to deal with alloc/free aspect for methods ...

I think it would. Assuming that the names always have a rather short length,
like less than 128 bytes or so, I figure allocating it as part of the main
struct or something would be better.

But that's actually a separate work from what you're doing, so you could just
as well do the alloc for now and then we could rework the code to do the
method names wthiout allocs in a second phase (which doesn't necessarily have
to be right now).

libssh2-devel mailing list
Received on 2009-03-29