I would alway prefer a reference rather than a copy - specially something like an array list. It is too costly yo copy. Rather it is far better to keep track of stuff and release based on life time. Inside the engine, for most of the cases, just a reference serves the purpose.

Samisa...

Damitha Kumarage wrote:
Hi,
In a situation like this

outflow = AXIS2_OP_GET_OUT_FLOW(app_msg_op_desc, env);
AXIS2_OP_SET_OUT_FLOW(create_seq_op, env, outflow);

Simply getting and setting the arraylist like this would leave to seg faults
when both operations try to free the flow. Therefore I would like to have
a new function in utilities

axis2_status_t AXIS2_CALL
axis2_utils_array_copy(
   const axis2_env_t *env,
   const axis2_array_list_t *array_to_copy)
{
    int size = 0, i = 0;
    axis2_array_list_t *new_array = NULL;
    if(array_to_copy)
        size = AXIS2_ARRAY_LIST_SIZE(array_to_copy, env);
    if(size > 0)
    {
         new_array = axis2_array_list_create(env, 0);
         if(!new_array)
         {
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
              return AXIS2_FAILURE;
          }
    }
    for(i = 0; i < size; i++)
   {
        void *item = AXIS2_ARRAY_LIST_GET(array_to_copy, env);
        AXIS2_ARRAY_LIST_ADD(new_array, env, item);
   }
   return new_array;
}


Or may be we can have this function in array_list it self

Damitha

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to