You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are lots of C APIs where a data structure has an array of pointers, with a NULL value indicating where that array ends.
It would be nice if I could tell NativeCall that some CArray returned by some C function is such an array, and prevent the user from reading the NULL, or anything beyond it.
This could also automatically append a NULL if necessary when a NativeCall managed CArray is passed to some C function.
For example:
my $environ = cglobal( Str, ‘environ’, CArray[Str] is NULL-terminated );
my %e = map split( ‘=’, *, 2 ), @$environ;
There are also C functions where the length is passed as a separate integer. It would be nice if, for this type of API, a CArray could be given an explicit length, which would then prevent the user from accidentally reading beyond the end of the array.
Perhaps something like:
sub poll( CArray[pollfd] $fds, int32 $nfds, int32 timeout –> int32 is CArray-elems(‘$fds’) ) is native;
It would also be nice if CArray did the role Iterable, though obviously only if it’s NULL terminated or the length has been assigned to.
Migrated from rt.perl.org#131399 (status was 'new')
Searchable as RT131399$
The text was updated successfully, but these errors were encountered: