Actually I fat fingered that, the typemap looks like this:

 

%typemap(in) const YMemoryPointer<unsigned char>

{

                if (Z_TYPE_PP($input) == IS_STRING)

                {

                                void *pData = Z_STRVAL_PP($input);

                                int size = Z_STRLEN_PP($input);

                                $1 = new YMemoryPointer<unsigned char>(pData, size, "Swig wrapper memory block");

                }

                else

                {

                                SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected string");

                }

}

 

 

From: Jason Dictos
Sent: Wednesday, January 28, 2009 9:33 AM
To: swig-user@lists.sourceforge.net
Subject: How to free memory after defining a typemap (in)

 

So we have this data class that we are constructing based on a PHP input param of type string. The typemap looks like this:

 

// Handle YMemoryPointer<unsigned char> conversions to the script language

%typemap(in) const YMemoryPointer<unsigned char> & (YMemoryPointer<unsigned char> temp

{

                if (Z_TYPE_PP($input) == IS_STRING)

                {

                                void *pData = Z_STRVAL_PP($input);

                                int size = Z_STRLEN_PP($input);

                                $1 = new YMemoryPointer<unsigned char>(pData, size, "Swig wrapper memory block");

                }

                else

                {

                                SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected string");

                }

}

 

 

The code in the wrapper cpp file though shows that the $1 assignment is not being deleted when the function is left. How do I free this variable?

 

-Jason