Skip Menu |

This queue is for tickets about the PDL-Graphics-PLplot CPAN distribution.

Report information
The Basics
Id: 105068
Status: new
Priority: 0/
Queue: PDL-Graphics-PLplot

People
Owner: Nobody in particular
Requestors: kmx [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Better handling of int-to-pointer and pointer-to-int conversion
Please consider applying the enclosed patch that tries to hadle all pointer conversions via perl core's macros PTR2IV and INT2PTR. This is especially important for 64bit MS Windows where "long" is not long enough for storing a pointer.

--
kmx

Subject: PDL-Graphics-PLplot-0.71_pointers.diff
diff -ru PDL-Graphics-PLplot-0.71/plplot.pd PDL-Graphics-PLplot-0.71_dev/plplot.pd --- PDL-Graphics-PLplot-0.71/plplot.pd 2015-05-15 22:50:41.000000000 +0200 +++ PDL-Graphics-PLplot-0.71_debug/plplot.pd 2015-06-08 10:04:38.095397400 +0200 @@ -1,8 +1,5 @@ use Config; -my $ptrsize = length($Config{'byteorder'}); # 4 or 8 bytes -my $int_ptr_type = ($ptrsize == 4) ? 'I32' : 'long'; - # User can set this global variable to 1 if he wants # to use the normal plplot order of arguments, not the PP-required # order for functions with OtherPars. @@ -3810,11 +3807,11 @@ $func (x, y, grid) double x double y - long grid + IV grid PPCODE: PLFLT tx, ty; - $func (x, y, &tx, &ty, (PLPointer) grid); + $func (x, y, &tx, &ty, INT2PTR(PLPointer, grid)); EXTEND (SP, 2); PUSHs (sv_2mortal (newSVnv ((double) tx))); @@ -3854,7 +3851,7 @@ for (i = 0; i < ny; i++) grid->yg[i] = $yg(ny => i); - $grid() = ('.$int_ptr_type.') grid;' + $grid() = PTR2IV(grid);' ); @@ -3863,9 +3860,9 @@ pp_addxs (<<"EOC"); void plFreeGrid (pg) - long pg + IV pg PPCODE: - PLcGrid* grid = (PLcGrid*) pg; + PLcGrid* grid = INT2PTR(PLcGrid*, pg); free (grid->xg); free (grid->yg); free (grid); @@ -3901,7 +3898,7 @@ grid->nx = nx; grid->ny = ny; - $grid() = ('.$int_ptr_type.') grid;' + $grid() = PTR2IV(grid);' ); @@ -3910,9 +3907,9 @@ pp_addxs (<<"EOC"); void plFree2dGrid (pg) - long pg + IV pg PPCODE: - PLcGrid2* grid = (PLcGrid2*) pg; + PLcGrid2* grid = INT2PTR(PLcGrid2*, pg); plFree2dGrid (grid->xg, grid->nx, grid->ny); plFree2dGrid (grid->yg, grid->nx, grid->ny); free (grid); @@ -3967,7 +3964,7 @@ get_standard_pltrcb (SV* cb) { if ( !SvROK(cb) ) return NULL; /* Added to prevent bug in plshades for 0 input. D. Hunt 12/18/2008 */ - IV sub = (IV) SvRV (cb); + IV sub = INT2PTR(IV, SvRV (cb)); if (sub == pltr0_iv) return (void*) pltr0; @@ -4175,9 +4172,9 @@ OtherPars => 'SV* p0; SV* p1; SV* p2;', Doc => 'FIXME: documentation here!', Code => ' - pltr0_iv = (IV) SvRV ($COMP(p0)); - pltr1_iv = (IV) SvRV ($COMP(p1)); - pltr2_iv = (IV) SvRV ($COMP(p2));'); + pltr0_iv = PTR2IV(SvRV ($COMP(p0))); + pltr1_iv = PTR2IV(SvRV ($COMP(p1))); + pltr2_iv = PTR2IV(SvRV ($COMP(p2)));'); pp_addpm (<<'EOPM'); init_pltr (\&pltr0, \&pltr1, \&pltr2); @@ -4273,7 +4270,7 @@ pltrcb = get_standard_pltrcb ($COMP(pltr)); if (pltrcb != pltr_callback) - pltrdt = (PLPointer) SvIV ($COMP(pltr_data)); + pltrdt = INT2PTR(PLPointer, SvIV ($COMP(pltr_data))); else pltrdt = $COMP(pltr_data); @@ -4314,7 +4311,7 @@ pltrcb = get_standard_pltrcb ($COMP(pltr)); if (pltrcb != pltr_callback) - pltrdt = (PLPointer) SvIV ($COMP(pltr_data)); + pltrdt = INT2PTR(PLPointer, SvIV ($COMP(pltr_data))); else pltrdt = $COMP(pltr_data); @@ -4490,7 +4487,7 @@ pltrcb = get_standard_pltrcb ($COMP(pltr)); if (pltrcb != pltr_callback) - pltrdt = (PLPointer) SvIV ($COMP(pltr_data)); + pltrdt = INT2PTR(PLPointer, SvIV ($COMP(pltr_data))); else pltrdt = $COMP(pltr_data); @@ -4558,7 +4555,7 @@ pltrcb = get_standard_pltrcb ($COMP(pltr)); if (pltrcb != pltr_callback) - pltrdt = (PLPointer) SvIV ($COMP(pltr_data)); + pltrdt = INT2PTR(PLPointer, SvIV ($COMP(pltr_data))); else pltrdt = $COMP(pltr_data); @@ -5434,7 +5431,7 @@ pltrcb = get_standard_pltrcb ($COMP(pltr)); if (pltrcb != pltr_callback) - pltrdt = (PLPointer) SvIV ($COMP(pltr_data)); + pltrdt = INT2PTR(PLPointer, SvIV ($COMP(pltr_data))); else pltrdt = $COMP(pltr_data);