curl-library
Re: Re: small patches for ssh (Daniel Stenberg) (Daniel Stenberg)
Date: Wed, 28 Dec 2011 17:19:47 +0100
-----Message d'origine-----
From: curl-library-request_at_cool.haxx.se
Sent: Tuesday, December 27, 2011 11:58 PM
To: curl-library_at_cool.haxx.se
Subject: curl-library Digest, Vol 76, Issue 54
Send curl-library mailing list submissions to
curl-library_at_cool.haxx.se
To subscribe or unsubscribe via the World Wide Web, visit
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
or, via email, send a message with subject or body 'help' to
curl-library-request_at_cool.haxx.se
Daniel Stenberg <daniel_at_haxx.se> wrote:
>On Mon, 26 Dec 2011, Tim Bannister wrote:
>
>>> + sshc->readdir_totalLen += 4 + sshc->readdir_len;
>>>
>>> sshc->readdir_currLen += snprintf(sshc->readdir_line +
>>> sshc->readdir_currLen,
>>
>> If this is the same ?4? as on line 1889:
>> new_readdir_line = realloc(sshc->readdir_line,
>> sshc->readdir_totalLen + 4 +
>> sshc->readdir_len);
>>
>> then would it make sense to assign this number once and then use the
>> constant for both cases? It's more clear, I think.
>
>Yes it is, and I think we can prevent the same addition to be used twice by
>simply doing it like this:
>
>--- a/lib/ssh.c
>+++ b/lib/ssh.c
>@@ -1885,9 +1885,9 @@ static CURLcode ssh_statemach_act(struct connectdata
>*conn
> Curl_safefree(sshc->readdir_linkPath);
> sshc->readdir_linkPath = NULL;
>
>- new_readdir_line = realloc(sshc->readdir_line,
>- sshc->readdir_totalLen + 4 +
>- sshc->readdir_len);
>+ /* get room for the filename and extra output */
>+ sshc->readdir_totalLen += 4 + sshc->readdir_len:
>+ new_readdir_line = realloc(sshc->readdir_line,
>sshc->readdir_totalLen);
> if(!new_readdir_line) {
> Curl_safefree(sshc->readdir_line);
> sshc->readdir_line = NULL;
>
>Armel, won't this work just as good in your case?
Your patch is equivalent to mine and avoids the copy of code, OK for me.
Regards
Armel
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-12-28