Andrew Hardy wrote:
I don't really undrstand what you're trying to achieve, but it looks a bit
I am trying to parse a bitstream, with minimal CPU usage, ie without using too many a malloc().
suspicious that you have pointers as part of your structs, this may give issues when you cast if you think you have structs wholely within structs.
I think this was the problem i have been facing..
Would something like this help?? char *ptr; // where storage contains what you want in enough space to coopy it out into your structs. ptr = storage; memcpy(somestruct, ptr, sizeof(somestruct)); ptr += sizeof(somestruct); memcpy(somestruct, ptr, sizeof(somestruct)); ptr += sizeof(somestruct); memcpy(somestruct, ptr, sizeof(somestruct)); ptr += sizeof(somestruct); etc... where your structures don't include pointers and where somestruct is the current of a number structures or if you require current of a number of substructures that you require to have in one struct.
Hmm, You mean to say, use the structs without the pointers ? Thanks, Manu