C
cpptutor2000
I am using an STL list to store data packets in a network simulator.
The data packets are really C structs, which have other C structs
inside them. These structs contain
unsigned char arrays of various sizes, and some unsigned int values.
There are no pointers values stored in these structs.
I have a function, from inside of which I have a loop as follows:
Please note that dataPacketStore is the name of the struct being
stored.
if(!dlist.empty()){
list<dataPacketStore>::iterator iter;
list<dataPacketStore>::iterator dbegin = dlist.begin();
list<dataPacketStore>::iterator dend = dlist.end();
for(iter = dbegin; iter != dend; iter++)
if((*iter).disabled == true) dlist.erase(iter);
//'disabled' is a boolean variable in the struct dataPacketStore
}
Calling this erase method causes a segmentation fault. Is this because
of the fact that nested structs are there? Any help or suggestions
would be greatly appreciated.
Thanks in advance for your help.
The data packets are really C structs, which have other C structs
inside them. These structs contain
unsigned char arrays of various sizes, and some unsigned int values.
There are no pointers values stored in these structs.
I have a function, from inside of which I have a loop as follows:
Please note that dataPacketStore is the name of the struct being
stored.
if(!dlist.empty()){
list<dataPacketStore>::iterator iter;
list<dataPacketStore>::iterator dbegin = dlist.begin();
list<dataPacketStore>::iterator dend = dlist.end();
for(iter = dbegin; iter != dend; iter++)
if((*iter).disabled == true) dlist.erase(iter);
//'disabled' is a boolean variable in the struct dataPacketStore
}
Calling this erase method causes a segmentation fault. Is this because
of the fact that nested structs are there? Any help or suggestions
would be greatly appreciated.
Thanks in advance for your help.