in reply to Re^7: SvUV vs SvIV for pointers in SVs, typemap
in thread SvUV vs SvIV for pointers in SVs, typemap

I'm making no such assumption. I'm saying nothing should be operating on the SV. If something does play with the internals of this object, it's their own fault if they mess something up.

Ask yourself how and why a pointer value might end up in the IV slot of an SV.

The XS library is creating a handle that will later be passed back to it.

In Windows, is HANDLE signed or unsigned? The answer is that it doesn't matter.

Update: Example use of that typemap:

$ cat a.pl use strict; use warnings; use Inline C => <<'__EOI__', PREFIX => 'M_'; #include <stdio.h> typedef struct { int i; int j; } foo_t; foo_t* M_get() { foo_t* foo = (foo_t*)malloc(sizeof(foo_t)); printf("get: %p\n", foo); return foo; } void M_free(foo_t* foo) { printf("free(%p)\n", foo); free(foo); } __EOI__ my $o = get(); free($o); $ cat typemap TYPEMAP foo_t* T_PTRREF $ perl -MInline=FORCE,NOISY,NOCLEAN a.pl ... get: 0x91ab70 free(0x91ab70)