[omniORB] Sequence length operation

Patrick Decat pdecat@lfvie.generali.fr
Tue, 12 Jun 2001 15:39:20 +0200


Hi,

in your implementation, nothing enforces that pd_max * 2 is at least equal
or greater than the length you take as a parameter.

Greetings,
Patrick.

----- Original Message ----- 
From: <jnye@micro-optics.com>
To: <omniorb-list@uk.research.att.com>
Sent: Tuesday, June 12, 2001 3:27 PM
Subject: [omniORB] Sequence length operation

[...]

> 
> Here is an implementation I propose:
> inline void length(_CORBA_ULong length)
> {
>     if (length > pd_max)
>     {
> ***        _CORBA_ULong pd_max_tmp = pd_max * 2; ***
> ***        ElemT* newbuf = new ElemT[pd_max_tmp]; ***
>         if( !newbuf )  _CORBA_new_operator_return_null();
>         for( unsigned long i = 0; i < pd_len; i++ )
>         newbuf[i] = pd_buf[i];
> ***        pd_max = pd_max_tmp; ***
>         if( pd_rel && pd_buf )  delete[] pd_buf;
>         else                    pd_rel = 1;
>         pd_buf = newbuf;
>     }
>     pd_len = length;
> }
> 
> Just a suggestion...
> 
> Cheers,
> Jason.
>