Hi,
I would like to write the following RPC method. My original idea is as
following:

int ns__Method(...struct Value *result)
{
   char **values;
   unsigned int index, current = 0;
   // do something...

   getValue(soap, "this", &num_values, &values);
   for (index = 0; index < num_values ; ++index) {
       result->ptrValue[current].Value = strdup(soap, values[index]);
       current++;
   }
   getValue(soap, "that", &num_values, &values);
   for (index = 0 ; index < num_values; ++index) {
       result->ptrValue[current].Value = strdup(soap, values[index]);
       current++;
   }
   return SOAP_OK;
}

int getValue(struct soap *soap, char *name, unsigned int *num_values,
char ***values)
{
   char **pptr;
   // do something...

   pptr = (char *) soap_malloc (soap, num);
   for (index = 0 ; index < num; ++index) {
      pptr[index] = soap_strdup(soap, tmp_value[index]);
   }

   *num_values = num;
   *values = pptr;
   return 0;
}

Now, I want to change ns__Method without strdup function. Is it right
operation?

int ns__Method(...struct Value *result)
{
   char **values;
   unsigned int index, current = 0;
   // do something...

   getValue(soap, "this", &num_values, &values);
   for (index = 0; index < num_values ; ++index) {
       result->ptrValue[current].Value = values[index];
       current++;
   }
   getValue(soap, "that", &num_values, &values);
   for (index = 0 ; index < num_values; ++index) {
       result->ptrValue[current].Value = values[index];
       current++;
   }
   return SOAP_OK;
}


Reply via email to