Could someone explain what this code does
size = *(int *)data; // size of string plus header word
off = (size + 3) & ~3;
chan = *(int *)(data + off);
data[size] = '\0'; // zero terminate
I think it’s got something to do with making the data a multiple of 4?
Assuming that
datais achar*…datais interpreted as a pointer-to-int, then dereferenced and assigned tosize.This rounds
sizeupwards to the nearest multiple of 4, and assigns tooff.The value for
chanapparently residesoffbytes fromdata.That one is obvious.