tags:

views:

27

answers:

0

I have a C interface that looks like this (simplified):

extern bool Operation(void ** ppData); 
extern float GetFieldValue(void* pData); 
extern void Cleanup(p); 

which is used as follows:

void * p = NULL; 
float theAnswer = 0.0f; 
if (Operation(&p)) 
{ 
   theAnswer = GetFieldValue(p); 
   Cleanup(p); 
} 

You'll note that Operation() allocates the buffer p, that GetFieldValue queries p, and that Cleanup frees p. I don't have any control over the C interface -- that code is widely used elsewhere.

I'd like to call this code from php via SWIG, but I was unable to find any good examples of how to pass a pointer to a pointer -- and retrieve its value.

I think the correct way to do this is by use of typemaps, but i haven't got it.