Hi,

I am trying to write an xs interface to an external library.  
My code takes two perl arrays, allocates and populates corresponding C structures, and 
passes them to the library routine.
The problem is that the program is unstable.  It will sometimes cause core dumps in 
the external library.  The library in itself is believed to be stable, so it seems to 
be something in the perl/C interface.  I use the following three functions to retrieve 
values from my perl objects in order to copy them into the C structures.
Does anyone see anything wrong here?

thank you,

Tamar
_______________________________________________________

char *
getString(HV * source, char * fieldName) 
{
  SV ** sv = hv_fetch(source, fieldName, strlen(fieldName), FALSE);
  if(!SvOK(*sv)) {
         printf("Error - hv_fetch %s returned bad sv\n", fieldName);
  }
  return SvPV(*sv, PL_na);
}

double
getDouble(HV * source, char * fieldName)
{
  SV ** sv = hv_fetch(source, fieldName, strlen(fieldName), FALSE);
  if(!SvOK(*sv)) {
         printf("Error - hv_fetch %s returned bad sv\n", fieldName);
  }
  return SvNV(*sv);
}

long
getLong(HV * source, char * fieldName)
{
  SV ** sv = hv_fetch(source, fieldName, strlen(fieldName), FALSE);
  if(!SvOK(*sv)) {
         printf("Error - hv_fetch %s returned bad sv\n", fieldName);
  }
  return SvIV(*sv);
}

Reply via email to