summaryrefslogtreecommitdiff
path: root/src/bin/util.c
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-09-04 19:45:05 +0000
committerpeter <peter@pmikkelsen.com>2026-09-04 19:45:05 +0000
commit4d1f519e1bcca659100a2593bd7ca7f2f4983ffe (patch)
treedf2b96f6bb871c8a52c8eda2ac2e2d87387d91bc /src/bin/util.c
parentcde3778df1f5086052d01bf770910b2e05d0a1e1 (diff)
Add a test which runs all the scripts in tests/scripts/good to meaure how many memory allocations they perform, and then rerun them with a mode that causes the memory allocator to fail after N allocations. The scripts are run for all values of N from 0 to the number of allocations they need to succeed.
FossilOrigin-Name: ed1953c203d3493d9c1adbcb9256d7d380bc1fdcfc7856f03f9d801291f478cd
Diffstat (limited to 'src/bin/util.c')
-rw-r--r--src/bin/util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bin/util.c b/src/bin/util.c
index b887447..c609e48 100644
--- a/src/bin/util.c
+++ b/src/bin/util.c
@@ -34,3 +34,19 @@ getenv_ulong(const char *name, unsigned long def)
}
return ret;
}
+
+long
+getenv_long(const char *name, long def)
+{
+ long ret, parsed;
+ char *env, *p;
+
+ ret = def;
+ env = getenv(name);
+ if((env != NULL) && (strlen(env) > 0)){
+ parsed = strtol(env, &p, 10);
+ if((*p) == 0)
+ ret = parsed;
+ }
+ return ret;
+}