<DIV> </DIV>
<DIV>HI!</DIV>
<DIV><BR>I am download omniORB-4.0.7-win32-vc7.zip,<BR>I am using omniORB_4.0.7 on Win2000 (MSVC++7.1) platforms,<BR>and the echo examples work fine .</DIV>
<DIV>Now I use data sequence,but have the problem :</DIV>
<DIV><BR>//----------IDL---------</DIV>
<DIV>struct NetDataItem<BR>{<BR> long id;<BR> string name;<BR>};</DIV>
<DIV>typedef sequence<NetDataItem> DataArray; <BR>typedef sequence<long> DataLongArray;</DIV>
<DIV>interface QDataSeq<BR>{<BR> DataArray QueryDatas(); <BR> DataLongArray QueryLongData(); <BR>};</DIV>
<DIV><BR>//---------server code--------------</DIV>
<DIV>// return struct data Sequence<BR>DataArray* QDataSeq_i::QueryDatas(){<BR> int cnt =100;<BR> DataArray_var datas = new DataArray((CORBA::Long)cnt);<BR> datas->length(cnt);<BR> for (int i =0;i< cnt; ++i)<BR> {<BR> datas[i].id = (CORBA::Long)(i+1);<BR> datas[i].name = CORBA::string_dup("aaaa"); // is OK??<BR> }<BR> std::cout << "OK" << endl;<BR> return datas._retn();<BR>}</DIV>
<DIV>// return long Sequence<BR>DataArray* QDataSeq_i::QueryLongData(){<BR> int cnt =100;<BR> DataLongArray_var datas = new DataLongArray((CORBA::Long)cnt);<BR> datas->length(cnt);<BR> for (int i =0;i< cnt; ++i)<BR> {<BR> datas[i] = (CORBA::Long)(i+1);<BR> }<BR> std::cout << "OK" << endl;<BR> return datas._retn();<BR>}</DIV>
<DIV><BR>//-----------client code-----------------------</DIV>
<DIV>this arises some exception of free sequence. why?</DIV>
<DIV>//query struct data Sequence , use _var<BR>void queryData(QDataSeq_ptr e)<BR>{<BR> DataArray_var dest = e->QuearyDatas();<BR> int len = pdest->length();<BR> std::cerr << "query sequence size :" << len << endl;<BR> //do something<BR>}<BR>/* use delete sequence ptr<BR>void queryData(QDataSeq_ptr e)<BR>{<BR> DataArray* pdest = e->QuearyDatas();<BR> int len = pdest->length();<BR> std::cerr << "query sequence size :" << len << endl;</DIV>
<DIV> //pdest->release(); <BR> delete pdest; // arise some exception. <BR> //If this isn't used 'delete' , it have memory leak,but run OK.<BR>}<BR>*/</DIV>
<DIV><BR>//query long Sequence. It is work fine and not have memory leak. <BR>void queryData(QDataSeq_ptr e)<BR>{<BR> DataArray_var dest = e->QuearyDatas();<BR> int len = pdest->length();<BR> std::cerr << "query sequence size :" << len << endl;<BR> //do something<BR>}</DIV>
<DIV>====================================<BR>Get a list of NetDataItem and display it, ERROR IN THE CLIENT.<BR>but Get a list of long ,it work fine.<BR>why?</DIV>
<DIV>Help me! <BR>How to fine use sequence of struct in the client and server?</DIV>
<DIV> </DIV>
<DIV>2006-10-16 roger007</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV > </DIV><br><!-- footer --><br><br><br><br><br><div style="border-bottom:1px solid #999"></div><br>
        <font color="black" style="font-size:14.8px">3G 时 代 来 临 了,坚 决 对 传 统 邮 箱 说 不 !</font>
        <br>
         <a href="http://www.126.com/" target="_blank" style="font-size:13px;line-height:160%;color:blue">新 一 代 极 速 3G 邮 箱 闪 亮 登 场 ,280 兆 网 盘 免 费 送 ! 点 击 此 处 注 册
</a>