Re: [AXIS2C] memory management

2007-06-19 Thread Dr. Florian Steinborn

Hi Samisa,




3. Do I understand correctly, nobody else frees the memory if not the  
user does it? Cannot imagine that - all the generated services would be  
giantic memory holes...
The model is that the user got to free it. The notion of "user got to  
free it" makes sense, as the user has control over the lifetime of the  
struct instance.


I think we had a misunderstanding. Of course the user has to free the  
memory that he allocates.
I had a deeper look into the generated free-functions and see that the  
axis2_skel__getString method is called in the "invoke" part  
and the memory is freed by the automatic call of  axis2_getString_free().  
If there is additional memory allocated by the user he has to free it  
himself.

I see.
Thanks,

Flori


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



Re: [AXIS2C] memory management

2007-06-19 Thread Samisa Abeysinghe

Dr. Florian Steinborn wrote:

Thanks for the answers - unfortunately it raises more questions...

1. "deep copy" - should this mean to really copy something (by 
allocating new memory) and not just let a pointer to point to a 
certain piece of memory?

Yes.


2. The function axis2_getStringResponse_set_return() is generated. The 
generated function can be seen here.


/**
  * setter for return
*/
axis2_status_t AXIS2_CALL
axis2_getStringResponse_set_return(
   axis2_getStringResponse_t* getStringResponse,
   const axutil_env_t *env,
   axis2_char_t*  param_return)
{

  AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
  if(!getStringResponse)
  {
  return AXIS2_FAILURE;
  }
  getStringResponse-> attrib_return = param_return;
  return AXIS2_SUCCESS;
}

The assignment of param_return does not look like a "deep copy", right? 

Yes it is a shallow copy.
As far as I understood, the only files that have to be touched after 
generation are the axis2_skel_.c files for the business logic...


3. Do I understand correctly, nobody else frees the memory if not the 
user does it? Cannot imagine that - all the generated services would 
be giantic memory holes...
The model is that the user got to free it. The notion of "user got to 
free it" makes sense, as the user has control over the lifetime of the 
struct instance.



4. Does someone have a reference implementation of a "deep copy" to 
look at?
The generated code is correct. What you have to do is to manage the 
memory in the business logic implementation.
In case of code generation, what can be done is to have a free method 
for axis2_getStringResponse_t struct. Then once you call 
axis2_skel__getString method, get the 
axis2_getStringResponse_t instance and use it, free the 
axis2_getStringResponse_t instance, which would free the members of the 
axis2_getStringResponse_t struct.


Samisa...



Thanks,
Flori


On Tue, 19 Jun 2007 07:51:31 +0200, Samisa Abeysinghe 
<[EMAIL PROTECTED]> wrote:



Shailesh Srivastava wrote:

Once the response string is formed, you need to free the local memory
allocated to "retVal".

If axis2_getStringResponse_set_return method does a deep copy you can 
free retVal. This should ideally be freed by 
axis2_getStringResponse_free method, that is to be called by user.


Samisa...


[...]

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





--
Samisa Abeysinghe : http://www.wso2.org/ (WSO2 Oxygen Tank - Web Services 
Developers' Portal)


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



Re: [AXIS2C] memory management

2007-06-19 Thread Dr. Florian Steinborn

Thanks for the answers - unfortunately it raises more questions...

1. "deep copy" - should this mean to really copy something (by allocating  
new memory) and not just let a pointer to point to a certain piece of  
memory?


2. The function axis2_getStringResponse_set_return() is generated. The  
generated function can be seen here.


/**
  * setter for return
*/
axis2_status_t AXIS2_CALL
axis2_getStringResponse_set_return(
   axis2_getStringResponse_t* getStringResponse,
   const axutil_env_t *env,
   axis2_char_t*  param_return)
{

  AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
  if(!getStringResponse)
  {
  return AXIS2_FAILURE;
  }
  getStringResponse-> attrib_return = param_return;
  return AXIS2_SUCCESS;
}

The assignment of param_return does not look like a "deep copy", right? As  
far as I understood, the only files that have to be touched after  
generation are the axis2_skel_.c files for the business logic...


3. Do I understand correctly, nobody else frees the memory if not the user  
does it? Cannot imagine that - all the generated services would be giantic  
memory holes...



4. Does someone have a reference implementation of a "deep copy" to look  
at?


Thanks,
Flori


On Tue, 19 Jun 2007 07:51:31 +0200, Samisa Abeysinghe <[EMAIL PROTECTED]>  
wrote:



Shailesh Srivastava wrote:

Once the response string is formed, you need to free the local memory
allocated to "retVal".

If axis2_getStringResponse_set_return method does a deep copy you can  
free retVal. This should ideally be freed by  
axis2_getStringResponse_free method, that is to be called by user.


Samisa...


[...]

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



Re: [AXIS2C] memory management

2007-06-18 Thread Samisa Abeysinghe

Shailesh Srivastava wrote:

Once the response string is formed, you need to free the local memory
allocated to "retVal".
  
If axis2_getStringResponse_set_return method does a deep copy you can 
free retVal. This should ideally be freed by 
axis2_getStringResponse_free method, that is to be called by user.


Samisa...

-Original Message-
From: Dr. Florian Steinborn [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 18, 2007 6:47 PM

To: axis-c-user@ws.apache.org
Subject: [AXIS2C] memory management

Hi friends,

just a "simple" question...
When you define a webservice that has an operation that returns a
string,  
you probably will get a generated function similiar to this:


/* starts here */

axis2_getStringResponse_t*
axis2_skel__getString ( const axutil_env_t *env  ,
 axis2_getString_t* getString )
{
 axis2_getStringResponse_t*  getStringRes = NULL;
 axis2_char_t*   retVal = NULL ;

 retVal = (axis2_char_t*) malloc( sizeof(char) * 20);
 strncpy( retVal, "NONSENS", 20);



 getStringRes = axis2_getStringResponse_create( env);
 axis2_getStringResponse_set_return( getStringRes, env, retVal) ;

 return getStringRes;

}

/* ends here */

The big question is: who cares for the memory allocated in "retVal" ? Do
I  
have to free it or is it freed automatically by the Axis2 machine after


serializing the answer? A small string may not be interesting but when
you  
have to fill structs or arrays of structs... ?


Thanks,

Flori

-
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]


  



--
Samisa Abeysinghe : http://www.wso2.org/ (WSO2 Oxygen Tank - Web Services 
Developers' Portal)


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



RE: [AXIS2C] memory management

2007-06-18 Thread Shailesh Srivastava
Once the response string is formed, you need to free the local memory
allocated to "retVal".

-Original Message-
From: Dr. Florian Steinborn [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 18, 2007 6:47 PM
To: axis-c-user@ws.apache.org
Subject: [AXIS2C] memory management

Hi friends,

just a "simple" question...
When you define a webservice that has an operation that returns a
string,  
you probably will get a generated function similiar to this:

/* starts here */

axis2_getStringResponse_t*
axis2_skel__getString ( const axutil_env_t *env  ,
 axis2_getString_t* getString )
{
 axis2_getStringResponse_t*  getStringRes = NULL;
 axis2_char_t*   retVal = NULL ;

 retVal = (axis2_char_t*) malloc( sizeof(char) * 20);
 strncpy( retVal, "NONSENS", 20);



 getStringRes = axis2_getStringResponse_create( env);
 axis2_getStringResponse_set_return( getStringRes, env, retVal) ;

 return getStringRes;

}

/* ends here */

The big question is: who cares for the memory allocated in "retVal" ? Do
I  
have to free it or is it freed automatically by the Axis2 machine after

serializing the answer? A small string may not be interesting but when
you  
have to fill structs or arrays of structs... ?

Thanks,

Flori

-
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]