c++ - Unallocatin an array to pointers of structers - Debug Assertion Failed -
I am trying to eliminate the method allocated my dynamic dynamically to the pointers of structeres. I want to rearrange each array area which is an indicator in different composition, remove it, and then delete [] the entire array. In the second iteration, I have a debug assignment. I have the code here:
Zero removal (SimpleStruct ** _ Simple Array Patterns, Int_isize) {if (0! = _simpleArrayPtrs) {for (int i = 0; i & lt; _iSize; ++ i) {If (0! = _simpleArrayPtrs [i]) {delete_simpleArrayPtrs [i]; _simpleArrayPtrs [i] = 0; }} Delete [] _simpleArrayPtrs; _simpleArrayPtrs = 0; Cout & lt; & Lt; "Deletion: Memory Delocated" & lt; & Lt; Endl; } And {cout & lt; & Lt; "[ERR] delete: invalid indicator" & lt; & Lt; Endl; }} SimpleStruct ** foo (int _iSize) {// local size variables int iSize = _iSize; SimpleStruct ** SimpleAreferences = 0; SimpleStruct * simpleArray = 0; // If allocation is succeded (0! = ISize) {// exception is not an indicator to avoid simple enthusiasm = new (std :: nothrow) SimpleStruct * [iSize]; SimpleAre = new (std :: nothrow) SimpleStruct [iSize]; If (0! = Simple array and 0! = SimpleAnother footer) {/ * Random seed start: * / srand (time (0)); For (Int i = 0; I
encoding delete_simpleArrayPtrs [i]
is incorrect
You do not assign dynamically _simpleArrayPtrs [i]
, so you should not dynamically implicate it.
Comments
Post a Comment