summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2025-04-24 16:46:04 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-04-24 16:46:04 +0200
commitfd1a43dbf894d37256bbf104dbcd3b341f8f1bee (patch)
tree09ecb369340a2ccf54f617fe9e8d57fdc4f68d1d
parent4861c35955a4e18b671b07c7b97252852501f535 (diff)
Posix 2008 doesn't say getcwd allocates, actually
-rw-r--r--faq/foo_max.mdwn5
1 files changed, 3 insertions, 2 deletions
diff --git a/faq/foo_max.mdwn b/faq/foo_max.mdwn
index 5f736680..cf5f80ba 100644
--- a/faq/foo_max.mdwn
+++ b/faq/foo_max.mdwn
@@ -35,8 +35,9 @@ memory page, thus a TLB lookup) when manipulating a lot of paths. Allocating
dynamically would use much less memory.
Most often interfaces can be made to properly allocate dynamically. Notably,
-since Posix 2008 `realpath(path, NULL)` and `getcwd(NULL, 0)` allocate the path
-dynamically.
+since Posix 2008 `realpath(path, NULL)` allocates the path dynamically.
+Posix 2008 does not say that `getcwd(NULL, 0)` allocates the path dynamically,
+but BSD, Linux, and even windows do.
In general, using `FOO_MAX` in source code (with a large value) leads to code
that is not actually checking against overflows. `PATH_MAX` being 4096 is