Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / CDR / octet_sequence.cpp
blobbed8e8c07a5f05aa02e419b18b357132c5e5123e
2 //=============================================================================
3 /**
4 * @file octet_sequence.cpp
6 * Verifies that reference counting is performed correctly for octet
7 * sequence marshaling.
9 * @author Dave Meyer (dmeyer@std.saic.com)Carlos O'Ryan (coryan@cs.wustl.edu)
11 //=============================================================================
14 #include "ace/Log_Msg.h"
16 #include "tao/CDR.h"
17 #include "ace/OS_NS_string.h"
19 ACE_Message_Block * m1;
20 ACE_Message_Block * m2;
21 ACE_Message_Block * m3;
23 void dump (const char * msg)
25 ACE_DEBUG ((LM_INFO,
26 "%C\n"
27 "m1: %d\n"
28 "m2: %d\n"
29 "m3: %d\n",
30 msg,
31 m1->data_block()->reference_count(),
32 m2->data_block()->reference_count(),
33 m3->data_block()->reference_count()));
36 int ACE_TMAIN (int, ACE_TCHAR *[])
38 // setup mb's
39 char buf[1024];
40 m1=new ACE_Message_Block(1024);
41 ACE_OS::memset(buf,'1',512);
42 m1->copy(buf,512);
43 m2=new ACE_Message_Block(1024);
44 ACE_OS::memset(buf,'2',512);
45 m2->copy(buf,512);
46 m3=new ACE_Message_Block(1024);
47 ACE_OS::memset(buf,'3',512);
48 m3->copy(buf,512);
50 m1->cont(m2);
51 m2->cont(m3);
52 dump("expect 1,1,1");
54 ACE_Message_Block* m = ACE_Message_Block::duplicate (m1);
55 dump("expect 2,2,2");
58 TAO_OutputCDR cdr;
59 cdr.write_octet_array_mb(m1);
60 dump("expect 3,3,3"); // that's what I expected, anyway
61 ACE_DEBUG ((LM_INFO, "total cdr length is %u\n",
62 static_cast<u_int> (cdr.total_length())));
64 dump("expect 2,2,2"); // that's what I expected, anyway
66 ACE_Message_Block::release (m);
67 dump("expect 1,1,1"); // that's what I expected, anyway
68 ACE_Message_Block::release (m1);
70 return 0;