[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391)
From: |
Josef Möllers |
Subject: |
Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391) |
Date: |
Fri, 17 Aug 2018 09:04:33 +0000 |
Josef Möllers commented on a discussion on libwget/bar.c:
> _bar_slot_t *slotp = &bar->slots[slot];
>
> xfree(slotp->filename);
> - slotp->filename = wget_strdup(filename);
> + if (++slotp->numfiles == 1) {
> + slotp->filename = wget_strdup(filename);
> + slotp->bytes_downloaded = 0;
> + } else {
> + char tag[128];
(Without checking): the filename passed in is the entire pathname and may well
be LOOOOOONG (hostname + whatever path name the source file has).
(wget_)strdup() will allocate enough storage to hold exactly that string (incl
terminating NUL), so nothing gets lost. This is the original code and I was
hesitant to break that ;-)
My new snippet just writes the string into a temporary buffer and the uses the
very same (wget_)strdup to allocate a buffer which is big enough to hold the
entire string.
We're not talking megabytes here, just a few (maybe hundereds of) bytes, so I'd
venture to say it doesn't hurt and, as I wrote earlier, at this point we should
not throw away information that we might want to use later (eg with scrolling
filenames).
--
Reply to this email directly or view it on GitLab:
https://gitlab.com/gnuwget/wget2/merge_requests/391#note_95086549
You're receiving this email because of your account on gitlab.com.
- [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Josef Möllers, 2018/08/17
- Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Darshit Shah, 2018/08/17
- Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Darshit Shah, 2018/08/17
- Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Josef Möllers, 2018/08/17
- Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Darshit Shah, 2018/08/17
- Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Josef Möllers, 2018/08/17
- Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Darshit Shah, 2018/08/17
- Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391),
Josef Möllers <=
- Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Darshit Shah, 2018/08/17
Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Darshit Shah, 2018/08/17
Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Darshit Shah, 2018/08/17
Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Darshit Shah, 2018/08/17
Re: [Wget-dev] wget2 | Fix progress display (issue #339) (!391), Josef Möllers, 2018/08/17