aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index a4b7229b..70ad0758 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -1293,3 +1293,16 @@ void do_lines(int fd, void (*call)(char **pline, long len))
if (fd) fclose(fp);
}
+
+// Returns the number of bytes taken by the environment variables. For use
+// when calculating the maximum bytes of environment+argument data that can
+// be passed to exec for find(1) and xargs(1).
+long environ_bytes()
+{
+ long bytes = sizeof(char *);
+ char **ev;
+
+ for (ev = environ; *ev; ev++)
+ bytes += sizeof(char *) + strlen(*ev) + 1;
+ return bytes;
+}