[omniORB] Resizing a string sequence
Duncan Grisby
duncan at grisby.org
Mon Nov 24 22:48:46 GMT 2003
On Monday 24 November, Johan Cronje wrote:
> attribute_list *component_attr;
>
> Then in the fn:
> attribute_list* return_attributes()
> {
> ...
> delete component_attr; // remove old value
> component_attr = new attribute_list;
> for (....)
> (*component_attr)[i] = ...
> ...
> return component_attr;
> }
>
> If there is something horribly wrong with this approach, _please_
> let me know!
It would be helpful if you explained what it was you were trying to
achieve. What is this return_attributes function? Is it the
implementation of a CORBA operation? Do you have a good reason for
making the component_attr sequence global?
The CORBA memory management rules are really very simple in this
respect (not in others). If this is a CORBA function, then it is the
caller's responsibility to free the returned sequence. It is a memory
error to do the delete at the start of return_attributes. By the time
that is reached, the sequence will have already been deleted.
Cheers,
Duncan.
--
-- Duncan Grisby --
-- duncan at grisby.org --
-- http://www.grisby.org --
More information about the omniORB-list
mailing list