[omniORB] Resizing a string sequence

Gary Duzan gduzan at bbn.com
Mon Nov 24 15:55:57 GMT 2003


In Message <200311241740.21950.jcronje at dsp.sun.ac.za> ,
   Johan Cronje <jcronje at dsp.sun.ac.za> wrote:

=>In my idl file I have the following:
=>
=>typedef string attributes;
=>typedef sequence<attributes> attribute_list;
=>
=>And in my application I have:
=>
=>protected:
=>  attribute_list component_attr;
=>// this is a global variable, as it is returned by following function
=>
=>  attribute_list* return_attributes()
=>  {
=>     ...
=>     component_attr.length(number_of_attributes);
=>     for (int i = 0; i < number_of_attributes; i++){
=>        component_attr[i] = CORBA::string_dup(string_obtained_from_fn);
=>     }
=>     ...
=>  }

   Are you returning &this->component_attr here? You can't do that.
Since "the caller owns the memory", the ORB will try to delete your
sequence object and fail, potentially causing all sorts of nastiness
similar to what you are seeing. You'll have to allocate and return a
new sequence object each time.

					Gary Duzan
					BBN Technologies
					A Verizon Company





More information about the omniORB-list mailing list