diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-03-01 23:15:26 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-03-01 23:15:26 -0800 |
commit | 06bd10fd45dc008fe0ea4909254b2e951e715809 (patch) | |
tree | 596f442e02bf5f9cd1f4ca80248373902e4d552d /tests | |
parent | 1134089866fde0478fe869aa6fa13e105325ddcd (diff) | |
download | txr-06bd10fd45dc008fe0ea4909254b2e951e715809.tar.gz txr-06bd10fd45dc008fe0ea4909254b2e951e715809.tar.bz2 txr-06bd10fd45dc008fe0ea4909254b2e951e715809.zip |
mapcar: avoid alloca proportional to number of args.
* eval.c (MAP_ALLOCA_LIMIT): New preprocessor symbol.
(map_common): If the number of args is greater than
MAP_ALLOCA_LIMIT, then allocate the array of seq_iter_t
structures from chk_malloc rather than alloca.
In case an exception might be thrown during the execution
of this function, we bind that memory to a buf object.
If we return normally, we call the new function buf_free
to release it. Otherwise we rely on the garbage collector.
* buf.[ch] (buf_free): New function.
* tests/012/seq.tl: Test case which hits this behavior.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/012/seq.tl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/012/seq.tl b/tests/012/seq.tl index 6ea572fe..21200268 100644 --- a/tests/012/seq.tl +++ b/tests/012/seq.tl @@ -822,3 +822,6 @@ (test (zip "ab" '(#\i #\j) #("x" "y")) ("aix" "bjy")) +(vtest + [apply mapcar join (list-seq "aaa".."zzz")] + (transpose (list-seq "aaa".."zzz"))) |