ATL / WTL / STL
|Windows 7, Visual Studio 2010, C++
structure m_common_data contains:
LPWSABUF p_lpwsabuf_array[ TCP_SERVER_PACKET_BUFFER_SIZE ];
where the constant has the value 16.
The main app dot H contains:
char m_send_buf_array[ TCP_SERVER_PACKET_BUFFER_SIZE ][TEST_BUFFER_SIZE];
where TEST_BUFFER_SIZE is an arbitrary 1024 for initial testing.
the main app dot CPP initializes all with this, and after some debugging variables were installed looks like this:
unsigned int db1, db2a, db2b, db2c, db2d, db3, db4, db5, db6, db7;
for( int i = 0; i < TCP_SERVER_PACKET_BUFFER_SIZE; i ++ )
for( int j = 0; j < TEST_BUFFER_SIZE; j ++ )
m_send_buf_array[ i ][ j ] = ( ( i * 5 ) + j ) % 255;
db1 = (unsigned int) &m_send_buf_array[ i ];
db2a = m_send_buf_array[ i ];
db2b = m_send_buf_array[ i ];
db2c = m_send_buf_array[ i ];
db2d = m_send_buf_array[ i ];
db3 = sizeof( m_send_buf_array[ i ] );
db4 = (unsigned int) &m_common_data;
db5 = (unsigned int) &( m_common_data.p_lpwsabuf_array[ i ] );
db6 = (unsigned int) &( m_common_data.p_lpwsabuf_array[ i ]->buf );
m_common_data.p_lpwsabuf_array[ i ]->buf = &m_send_buf_array[ i ];
m_common_data.p_lpwsabuf_array[ i ]->len = sizeof( m_send_buf_array[ i ] );
When stopped on the first time through the i loop, i = 0.
The debugger shows
db1 = a valid looking address
dba,b,c, and d contain: 0, 1, 2, 3, as expected
db3 = 0X400, expected
db4 looks like a valid address
db5 = db4 + 0xF0 again expected because of items not shown.
db6 shows the value 4.
db6 is the value I do not comprehend. I expected a valid address here, specifically I expected the value to be 4 larger than db5 because the ->buf item of structure WSABUF is the second item in the structure.
Please explain why db6 has the value 4 rather than the address of item ->buf.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 14-Aug-14 11:56am.
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.