Click here to Skip to main content
14,638,192 members
Home » Discussions » ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Additional Include Directories Pin
bkelly1324-Mar-13 13:47
Memberbkelly1324-Mar-13 13:47 
GeneralRe: Additional Include Directories Pin
SoMad24-Mar-13 14:00
professionalSoMad24-Mar-13 14:00 
GeneralRe: Additional Include Directories Pin
bkelly1324-Mar-13 14:11
Memberbkelly1324-Mar-13 14:11 
GeneralRe: Additional Include Directories Pin
SoMad24-Mar-13 14:40
professionalSoMad24-Mar-13 14:40 
AnswerRe: Additional Include Directories Pin
Richard MacCutchan24-Mar-13 23:37
mveRichard MacCutchan24-Mar-13 23:37 
GeneralRe: Additional Include Directories Pin
bkelly1325-Mar-13 16:14
Memberbkelly1325-Mar-13 16:14 
GeneralRe: Additional Include Directories Pin
Richard MacCutchan25-Mar-13 23:41
mveRichard MacCutchan25-Mar-13 23:41 
Questionmemcpy, not understanding something Pin
bkelly1311-Mar-13 14:11
Memberbkelly1311-Mar-13 14:11 
Windows 7, Visual Studio 2008, MFC, C++
A memset is not doing what I expect. Here is the relevant code. It is a received TCP/IP payload packet and the goal is to copy some of the data to a new location. m_carry_over_bytes has the expected value of 1200.

All the code surrounding the memcpy is just to look at the before and after.

m_prev_header_packet_size     = mp_search_pointer->iads_structure.header.packet_size;
 m_prev_header_sequence_number = mp_search_pointer->iads_structure.header.sequence_number;
 m_prev_header_packets_sent    = mp_search_pointer->iads_structure.header.packets_sent;
 m_prev_header_packets_lost    = mp_search_pointer->iads_structure.header.loss_or_overflow;
 m_prev_header_dummy_0_5555    = mp_search_pointer->iads_structure.header.dummy[0];
 m_prev_header_dummy_1_6666    = mp_search_pointer->iads_structure.header.dummy[1];
 m_prev_header_dummy_2_7777    = mp_search_pointer->iads_structure.header.dummy[2];
 m_prev_header_dummy_3_ffff    = mp_search_pointer->iads_structure.header.dummy[3];


 memcpy( &m_carry_over_buffer,
         &mp_search_pointer,
         m_carry_over_bytes );

 m_curr_header_packet_size     = m_carry_over_buffer.iads_structure.header.packet_size;
 m_curr_header_sequence_number = m_carry_over_buffer.iads_structure.header.sequence_number;
 m_curr_header_packets_sent    = m_carry_over_buffer.iads_structure.header.packets_sent;
 m_curr_header_packets_lost    = m_carry_over_buffer.iads_structure.header.loss_or_overflow;
 m_curr_header_dummy_0_5555    = m_carry_over_buffer.iads_structure.header.dummy[0];
 m_curr_header_dummy_1_6666    = m_carry_over_buffer.iads_structure.header.dummy[1];
 m_curr_header_dummy_2_7777    = m_carry_over_buffer.iads_structure.header.dummy[2];
 m_curr_header_dummy_3_ffff    = m_carry_over_buffer.iads_structure.header.dummy[3];


Looking at the m_prev* variables I find the expected values: size is 1228, sequence_number is 62316, ... dummy 2 is 0x7777, etc

After the memcpy, the m_curr* values are expected to have the same values ad the m_prev* values. Instead they have all Fs, the value it was initialized to in the constructor.

Both the source and destination work back to this structure:
// 
  union RECEIVE_TYPE
  {
     char char_array [ C_TCP_MAX_RECEIVE_SIZE ];
     C_IADS_TD_FIXED_PARAMETER_PACKET iads_structure;
  } m_receive_buffer;



I expected this memcpy to be simple. Where am I not understanding it?
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/


modified 11-Mar-13 20:47pm.

AnswerRe: memcpy, not understanding something Pin
H.Brydon11-Mar-13 14:41
professionalH.Brydon11-Mar-13 14:41 
GeneralRe: memcpy, not understanding something Pin
bkelly1311-Mar-13 14:53
Memberbkelly1311-Mar-13 14:53 
AnswerRe: memcpy, not understanding something Pin
Richard MacCutchan11-Mar-13 22:35
mveRichard MacCutchan11-Mar-13 22:35 
GeneralRe: memcpy, not understanding something Pin
Dale Burr28-Apr-13 22:01
MemberDale Burr28-Apr-13 22:01 
Questionmember char array is bad pointer Pin
bkelly139-Mar-13 16:41
Memberbkelly139-Mar-13 16:41 
AnswerRe: member char array is bad pointer Pin
Richard MacCutchan9-Mar-13 22:40
mveRichard MacCutchan9-Mar-13 22:40 
GeneralUnexpected result Pin
bkelly1310-Mar-13 6:09
Memberbkelly1310-Mar-13 6:09 
GeneralRe: member char array is bad pointer Pin
bkelly1310-Mar-13 7:29
Memberbkelly1310-Mar-13 7:29 
GeneralRe: member char array is bad pointer Pin
Richard MacCutchan10-Mar-13 8:04
mveRichard MacCutchan10-Mar-13 8:04 
Generalresolved, with many curses directed at myself Pin
bkelly1310-Mar-13 7:38
Memberbkelly1310-Mar-13 7:38 
GeneralRe: resolved, with many curses directed at myself Pin
Richard MacCutchan10-Mar-13 8:05
mveRichard MacCutchan10-Mar-13 8:05 
GeneralRe: resolved, with many curses directed at myself Pin
Albert Holguin10-Mar-13 14:27
professionalAlbert Holguin10-Mar-13 14:27 
GeneralRe: resolved, with many curses directed at myself Pin
bkelly1310-Mar-13 15:44
Memberbkelly1310-Mar-13 15:44 
GeneralRe: resolved, with many curses directed at myself Pin
Albert Holguin10-Mar-13 15:49
professionalAlbert Holguin10-Mar-13 15:49 
Generalsomething new to me Pin
bkelly1310-Mar-13 16:14
Memberbkelly1310-Mar-13 16:14 
GeneralRe: something new to me Pin
Albert Holguin11-Mar-13 7:53
professionalAlbert Holguin11-Mar-13 7:53 
Questionrookie need help with STL Pin
spawn200420-Feb-13 7:40
Memberspawn200420-Feb-13 7:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.