[omniORB] Allocation of memory for sequence "vars"
Gary Duzan
gduzan at bbn.com
Tue Sep 21 14:56:37 BST 2004
In Message <002b01c49ff8$3a09c0c0$680da8c0 at int.yeomannavigation.co.uk> ,
"Clarke Brunt" <clarke.brunt at yeomannavigation.co.uk> wrote:
=>I'm never sure how this is intended to be handled either. I've sometimes
=>wanted to use a _var type, and to be able to check whether it currently does
=>or doesn't contain anything.
=>
=>Obviously, you can check the allocation before assigning to the _var
=>
=>SEQ::ABSseq *pme = new SEQ::ABCseq;
=>if (pme == NULL) error...
=>SEQ::ABCseq_var me = pme;
=>
=>but that doesn't seem very tidy.
=>
=>Or you can get at the contained pointer using operator->(), i.e.
=>if (pme.operator->() == NULL) error...
=>
=>but the spec. seems to say that you aren't strictly allowed to call
=>operator-> before assigning a valid pointer. Then again, perhaps NULL _is_ a
=>valid pointer, albeit to nowhere. Indeed I might consider assigning a NULL
=>to the _var to 'empty it out'. The _var also probably has a conversion
=>operator to 'const ABCseq&' for use as an 'in' arg. Its in() method will
=>produce the same thing. So you could have something equally horrid-looking
=>like
=>
=>if (&me.in() == NULL) error...
=>
=>And, remember that although you might succeed in allocating the sequence, it
=>still has a length of zero (with the default constructor). If you want to
=>check every memory allocation, you're going to have to worry about what
=>happens when you e.g. call length(n) on it.
=>
=>So, what does anyone else think? What _are_ you supposed to do?
Michi Henning and I hashed this out on comp.object.corba a while
back:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=3D5A0E93.3060108%40ics.forth.gr
It basically ended with Michi declaring it a problem with the spec
and opening a defect against the C++ mapping with the OMG. I don't
know if that ever went anywhere.
Gary Duzan
BBN Technologies
More information about the omniORB-list
mailing list