Skip to content

Commit

Permalink
Try out a fix for memory freeing issue in warp2d.
Browse files Browse the repository at this point in the history
There seems to be a problem with threads and Windows and freeing
memory.  Previously the warp2d test would crash on Strawberry Perl
with a "free to wrong pool" error.

I followed the advice from BrowserUK in this PerlMonks thread:
http://www.perlmonks.org/?node_id=742205 to create a pass-through
routine to free the interolation kernel's memory.  Thanks for asking
the similar question 9 years ago, Rob!

These changes don't cause any tests to fail on my Mac, we shall see
on the AppVeyor.
  • Loading branch information
d-lamb committed Feb 26, 2018
1 parent 4b59727 commit b31bf64
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/Image2D/image2d.pd
Expand Up @@ -2448,7 +2448,7 @@ sub PDL::warp2d {
%} /* threadloop */
free(poly);
free(kernel) ;
kernel_free(kernel) ;
',
); # pp_def: warp2d
Expand Down Expand Up @@ -2539,7 +2539,7 @@ sub PDL::warp2d_kernel ($) {
%}
/* free the kernel */
free( kernel );
kernel_free( kernel );
'); # pp_addpm

Expand Down
5 changes: 5 additions & 0 deletions Lib/Image2D/resample.c
Expand Up @@ -357,6 +357,11 @@ generate_interpolation_kernel(char * kernel_type)

} /* generate_interpolation_kernel() */

void kernel_free( void *p ) {
#undef free
free( p );
}

/***********
*** END ***
***********/
3 changes: 3 additions & 0 deletions Lib/Image2D/resample.h
Expand Up @@ -39,4 +39,7 @@ poly2d_compute( int ncoeff, double *c, double u, double *vpow );
double *
generate_interpolation_kernel(char * kernel_type);

void
kernel_free(void *p);

#endif

0 comments on commit b31bf64

Please sign in to comment.