Skip to content

Conversation

@astamm
Copy link
Collaborator

@astamm astamm commented May 9, 2025

Everything can be found in r-lib/cpp11#456.

For the time being, I vendored {cpp11} headers and patched them. Specifically:

Fix for insert() in protect.hpp.

The key changes were to remove PROTECT/UNPROTECT calls since:

  • list from get() is already preserved;
  • The cons cell is part of the preserve list structure;
  • The input x is protected by the caller.

Fixes in r_vector.hpp

Key changes to reserve_data()

  1. Removed all explicit PROTECT/UNPROTECT calls since protection is handled by the safe wrapper in both resize_data and resize_names()
  2. Simplified the flow of the names handling
  3. Let R's garbage collection handle the intermediate objects

Key change to resize_data()

  1. Moving both the PROTECT and UNPROTECT calls since the safe wrapper around Rf_allocVector already handles protection.

Key changes to resize_names()

  1. The safe wrapper around Rf_allocVector already handles protection
  2. Removed direct pointer access via STRING_PTR_RO
  3. Use STRING_ELT instead of direct pointer access

@astamm astamm merged commit 6d80be9 into main May 9, 2025
9 checks passed
@astamm astamm deleted the fix-cpp11-rchk branch May 9, 2025 19:54
@astamm astamm mentioned this pull request May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants