Passing a gdImagePtrPtr type

Chris Fuhrman cfuhrman at tfcci.com
Thu May 11 09:11:09 PDT 2000


Howdy,

Having an interesting problem with getting MapScript/Perl to correctly
pass a gdImagePtrPtr type to a subroutine (you get a gdImagePtrPtr type
when you call $MapObj->prepareImage()).  What's happening is that I'm
finding that the gdImagePtrPtr type is exceptionally volatile.  Here's an
example of what I'm trying to do:

main : {

  # blah blah blah

  $img = $map->prepareImage();

  RenderBase($dbh,
  	     $cgi,
             $img);

  # Do some other stuff ...

  mapscript::msSaveImage($img, "temp.png", 1, 1);

} # main

Unfortunately, this doesn't work.  It produces a blank image.  I believe
that somewhere down the line, $img is getting clobbered at one point or
else is pointing to memory that's been deallocated.  Now, something like
this *does* work:

sub MySubroutine {

  $img = $map->prepareImage();

  # Generate Image ...

  mapscript::msSaveImage($img, "temp.png", 1, 1);

} # MySubroutine

Essentially, what I'm trying to do is successfully pass $img to a
subroutine and then get the new value back.  I've tried the following to
no avail:

* Make $img a global variable

* Pass in $img and make the subroutine return the new value

* Pass in $img as a reference and dereference it within the subroutine.

* Pass in $img as a regular variable and assume it's pointing to the
  correct data.

I've gone through the perl debugger and it looks like $img is pointing to
the same address space throughout which leads me to the conclusion that
somewhere down the line, the memory is getting deallocated.

Does anyone have any experience with this?

-- 
Chris Fuhrman           | Twenty First Century Communications
cfuhrman at tfcci.com      | Software Engineer
(W) 614-442-1215 x271   |
(F) 614-442-5662        | PGP/GPG Public Key Available on Request




More information about the MapServer-users mailing list