X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Message-ID: <492C3128.8000700@draigBrady.com>
Date: Tue, 25 Nov 2008 17:08:56 +0000
From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= <P@draigBrady.com>
User-Agent: Thunderbird 2.0.0.6 (X11/20071008)
MIME-Version: 1.0
To: Jim Meyering <jim@meyering.net>
CC: Eric Blake <ebb9@byu.net>, cygwin@cygwin.com,
   bug-coreutils <bug-coreutils@gnu.org>
Subject: Re: "du -b --files0-from=-" running out of memory
References: <nacii4p76633jbufvfoj4qjesrph05rjga@4ax.com>	<49296551.4010801@byu.net> <87bpw5a5tp.fsf@rho.meyering.net>	<874p1v52od.fsf@rho.meyering.net> <492C1512.9020706@draigBrady.com> <87myfn3ft5.fsf@rho.meyering.net>
In-Reply-To: <87myfn3ft5.fsf@rho.meyering.net>
Content-Type: text/plain; charset="UTF-8"
x-MXSweep-CtasdSpam: Unknown
x-MXSweep-CtasdVirus: Unknown
x-MXSweep-KeywordsCount: 0
x-MXPurifier-SpamScore: 0
x-MXPurifier-VirusScore: 0
X-MXSweep-Threat: Clean
X-MXUniqueID: dc034ecd-5e12-45b1-ac8f-6bbc7119f2f3
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id mAPHA4LD032675

Jim Meyering wrote:
> Pádraig Brady <P@draigBrady.com> wrote:
>> Jim Meyering wrote:
>>> Subject: [PATCH 1/2] argv-iter: new module
>>>
>>> * gl/lib/argv-iter.h: New file.
>>> * gl/lib/argv-iter.c: New file.
>>> * gl/modules/argv-iter: New file.
>> Very useful module!
>>
>> I see that --files0-from was added to `du` in Mar 2004,
>> so it's a nice solution to this 4 year old issue.
> 
> Thanks.
> I'm surprised it took so long to bite.
> 
>> I notice that argv_iter does a malloc() + memcpy() per entry.
>> Since the sources are already NUL terminated strings
>> perhaps it could just return a pointer to a getdelim
>> realloc'd buffer which was referenced in the argv_iterator struct.
> 
> The only per-entry allocation I see is:
>   - in argv-mode: strdup
>   - in stream-reading mode: getdelim
> 
> Did I miss something?

Sorry I was unclear.
strdup() and getdelim(NULL,...) do a malloc() + memcpy()
if you maintain the char* name and size_t buf_len in
the argv_iterator struct, then you can return pointers
to the orig data, and remove the need to free() from the
users of argv_iter().

Pádraig.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


