Something::methodname()
{
(unsigned char*) ptr = (unsigned char*) m_pptr;
while ((*ptr || *(ptr+1)) && (((unsigned char*)m_pptr+BUFSIZE)<ptr))
ptr++;
if(ptr == m_pptr)
return ptr;
return ptr + 1;
}
m_pptr is a protected member of a class. ptr is local to this function
Could someone help me with the logic of this code? I know it compiles but the answers I’m getting out are not the ones I’m expecting. I am memset-ing a buffer full of A5’s and the while loop fails somehow. It skips right past it. Any help would be great.
This will go through a buffer and if the value of the pointer or the value of (ptr+1) is true it will increment the pointer AND the ptr can’t exceed the size of the buffer(which is found by m_pptr “pointer to the beginning of the buffer” + buffer size) has to be true also. The if statement says if m_pptr(pointer to beginning of the buffer is the same as ptr then return just the pointer.
this function returns a void* and is passed nothing
looks backward:
would be more likely; Even more sane: