[omniORB] typed BLOBs as sequence<octet>

Duncan Grisby dgrisby@uk.research.att.com
Mon, 26 Nov 2001 17:27:58 +0000


On Monday 26 November, "Haarek Ryeng" wrote:

> Is it safe to assume that the OmniORB client app. receives a
> contiguous data buffer when receiving a sequence<octet>?
>
> Client ex.:
> MySeq = GetData(); // sequence<octet>
> NonIDLTranslateable* p = (NonIDLTranslateable*) MySeq.get_buffer();

Since you have used get_buffer(), you are safe. A sequence could, in
theory, use multiple buffers in normal use, but as soon as you call
get_buffer(), it has to coalesce them into a single buffer. You could
only get into trouble if you did something like

  MySeq = GetData(); // sequence<octet>
  NonIDLTranslateable* p = (NonIDLTranslateable*)&(MySeq[0]);

In fact, omniORB's current implementation always uses a single buffer,
so you'd always get away with it, but it's non-portable (and ugly).

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --