Skip to content
Prev 63005 / 63424 Next

R should add an API routine for safe use of memcpy(), memset() for use with 0-length SEXP

h/t Tim Taylor for pointing out my blindspot :)

We have Memcpy() in API already [1], which wraps a 0-aware R_chk_memcpy() [2].

We don't quite have Memset() in API, though; instead we have Memzero()
[3] for R_chk_memset(s, 0, n) which is 0-aware memset() [4].

[1] https://github.com/r-devel/r-svn/blob/9e597ca8132e8b6298b0bedb39fa8deba5c819df/src/include/R_ext/RS.h#L59-L60
[2] https://github.com/r-devel/r-svn/blob/9e597ca8132e8b6298b0bedb39fa8deba5c819df/src/main/memory.c#L3575-L3580
[3] https://github.com/r-devel/r-svn/blob/9e597ca8132e8b6298b0bedb39fa8deba5c819df/src/include/R_ext/RS.h#L62-L63
[4] https://github.com/r-devel/r-svn/blob/9e597ca8132e8b6298b0bedb39fa8deba5c819df/src/main/memory.c#L3582-L3587

Mike C

On Wed, Apr 23, 2025 at 8:57?AM Michael Chirico
<michaelchirico4 at gmail.com> wrote: