This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "du -b --files0-from=-" running out of memory


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]