struct - deque::push_back() in c++ -
i have 2 structs in code
struct node { int no; node* next1; node* next2; char path1; char path2; }; struct nodeset { node* entry; node* exit; }; and deque
deque<nodeset> nsqueue[100] the problem when runs to: nsqueue[level+1].push_back(ns) before execution: +
ns {entry=0x0026f5a0 {no=2 next1=0x0026f350 {no=3 next1=0x002999e8 {no=4 next1=0x00299a38 {...} next2=0xcdcdcdcd {...} ...} ...} ...} ...} nodeset after execution: +
ns {entry=0x0026f5a0 {no=2 next1=0x0026f350 {no=-858993460 next1=0x00000000 {no=??? next1=??? next2=??? ...} ...} ...} ...} nodeset why values change? help.
i suspect list of node objects ns nodeset pointed no longer valid (ie., objects no alive anymore) reason, memory being reused push_back() call. 1 clue call push_back() trashed memory, clue of memory dump includes:
- after
push_back():no=-858993460equivalentno=0xcccccccc. pattern used ms compilers initialize automatic variables (that aren't explicitly initialized code) detect using initialized variables.
also, before push_back(), dump shows next2=0xcdcdcdcd. pattern used debug heap runtime fill 'clean memory' indicates memory has been allocated not written application since allocation. might not bug (it's valid not write allocated memory, long don't otherwise use it), it's indication @ least of objects in list of node structs might not quite right.
Comments
Post a Comment