[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] stat: don't explicitly request file size for filenames

From: Bruno Haible
Subject: Re: [PATCH] stat: don't explicitly request file size for filenames
Date: Sat, 06 Jul 2019 00:56:18 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-151-generic; KDE/5.18.0; x86_64; ; )

> Therefore I think it would be good to add a "Shrink BUF before returning it."
> logic also to
>   areadlink-with-size.c
>   areadlinkat-with-size.c
>   etc.

Done as follows:
- For areadlink-with-size, areadlinkat-with-size, xgethostname, xgetdomainname
  by shrinking the result before returning it.
- In getcwd-lgpl and getcwd, shrinking is already done. But it may call
  realloc (P, SIZE) when the block allocated is already of size SIZE. It
  ought to be a no-op, but actually isn't on all platforms (on MSVC when
  SIZE is one of 8, 16, 32, ..., 16384).
- I'm not touching getdelim.c, because the calling convention of this function
  is made for calling getdelim() in a loop, and the buffer is meant to
  occasionally grow, not constantly grow and shrink and grow shrink ...

Attachment: 0001-areadlink-with-size-Don-t-return-an-excessive-memory.patch
Description: Text Data

Attachment: 0002-areadlinkat-with-size-Don-t-return-an-excessive-memo.patch
Description: Text Data

Attachment: 0003-xgethostname-Don-t-return-an-excessive-memory-alloca.patch
Description: Text Data

Attachment: 0004-xgetdomainname-Don-t-return-an-excessive-memory-allo.patch
Description: Text Data

Attachment: 0005-getcwd-lgpl-getcwd-Don-t-call-realloc-when-it-is-poi.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]