@@ -2311,6 +2311,11 @@ pp_addhdr(<<'EOH');
2311
2311
#define PDL PDL_Graphics_PLplot
2312
2312
Core* PDL = NULL; PDL_COMMENT("Structure hold core C functions")
2313
2313
#endif
2314
+
2315
+ #define PLPTR_DEFINE(t) typedef t *t ## Ptr;
2316
+ PLPTR_DEFINE(PLcGrid)
2317
+ PLPTR_DEFINE(PLcGrid2)
2318
+ #define PLPTR_RECEIVE_IN(t, v, v_in) t *v = (t *)v_in;
2314
2319
EOH
2315
2320
2316
2321
# The create_low_level_constants function is used to make the #define'd
@@ -3847,25 +3852,22 @@ pp_def ('plrandd',
3847
3852
# pltr1: Linear interpolation from singly dimensioned coord arrays
3848
3853
# Linear interpolation from doubly dimensioned coord arrays
3849
3854
3850
- for my $func (' pltr0', ' pltr1', ' pltr2' ) {
3851
-
3855
+ for my $t ([qw( pltr0 SV*)], [qw( pltr1 PLcGridPtr)], [qw( pltr2 PLcGrid2Ptr)] ) {
3856
+ my ($func, $type) = @$t;
3852
3857
pp_addxs (<<"EOC");
3853
3858
void
3854
- $func (x, y, grid)
3859
+ $func(x, y, grid)
3855
3860
double x
3856
3861
double y
3857
- long grid
3862
+ $type grid
3858
3863
PPCODE:
3859
3864
PLFLT tx, ty;
3860
-
3861
- $func (x, y, &tx, &ty, (PLPointer) grid);
3862
-
3865
+ $func(x, y, &tx, &ty, (PLPointer) grid);
3863
3866
EXTEND (SP, 2);
3864
- PUSHs (sv_2mortal (newSVnv ((double) tx)));
3865
- PUSHs (sv_2mortal (newSVnv ((double) ty)));
3867
+ PUSHs(sv_2mortal(newSVnv((double) tx)));
3868
+ PUSHs(sv_2mortal(newSVnv((double) ty)));
3866
3869
EOC
3867
-
3868
- pp_add_exported ($func);
3870
+ pp_add_exported($func);
3869
3871
}
3870
3872
3871
3873
pp_def ('plAllocGrid',
@@ -3897,12 +3899,12 @@ pp_def ('plAllocGrid',
3897
3899
pp_addxs (<<"EOC");
3898
3900
void
3899
3901
plFreeGrid (pg)
3900
- long pg
3902
+ PLcGridPtr pg
3901
3903
PPCODE:
3902
- PLcGrid* grid = (PLcGrid*) pg;
3903
- free (grid->xg);
3904
- free (grid->yg);
3905
- free (grid);
3904
+ PLPTR_RECEIVE_IN( PLcGrid, grid, pg)
3905
+ Safefree (grid->xg);
3906
+ Safefree (grid->yg);
3907
+ Safefree (grid);
3906
3908
EOC
3907
3909
3908
3910
pp_add_exported (plFreeGrid);
@@ -3934,9 +3936,9 @@ pp_def ('plAlloc2dGrid',
3934
3936
pp_addxs (<<"EOC");
3935
3937
void
3936
3938
plFree2dGrid(pg)
3937
- long pg
3939
+ PLcGrid2Ptr pg
3938
3940
PPCODE:
3939
- PLcGrid2* grid = (PLcGrid2*) pg;
3941
+ PLPTR_RECEIVE_IN( PLcGrid2, grid, pg)
3940
3942
plFree2dGrid(grid->xg, grid->nx, grid->ny);
3941
3943
plFree2dGrid(grid->yg, grid->nx, grid->ny);
3942
3944
free(grid);
0 commit comments