Pointers
-
Hey Guys I have declared a structure i created on the freestore in a function. This structure contains pointers which i assign arrays to i then use delete[] on these pointers in the structure to free memory but thsi causes an error. Any Ideas Peter P.S this is my structure struct SignFileStructure { SignFileHeader FileHeader; //Header Structure //DWORD dwSizeOfFileStruct; //Size of Data Struct BYTE *psMessage; //Pointer to message array SignedBlobs *pSignedBlob; //Pointer to array of signed blob pointers CounterSignedBlobs *pCounterSigBlob; //Pointer to array of counter signed blob pointers }; and this is my delete[] bit //Delete all variables used to free memory //------------------------------------------------------------------------------------------------------------ delete[] SignedFileData.psMessage; delete[] SignedFileData.pSignedBlob; delete[] SignedFileData.pCounterSigBlob; SignedFileData.psMessage = NULL; SignedFileData.pSignedBlob = NULL; SignedFileData.pCounterSigBlob = NULL; //------------------------------------------------------------------------------------------------------------
-
Hey Guys I have declared a structure i created on the freestore in a function. This structure contains pointers which i assign arrays to i then use delete[] on these pointers in the structure to free memory but thsi causes an error. Any Ideas Peter P.S this is my structure struct SignFileStructure { SignFileHeader FileHeader; //Header Structure //DWORD dwSizeOfFileStruct; //Size of Data Struct BYTE *psMessage; //Pointer to message array SignedBlobs *pSignedBlob; //Pointer to array of signed blob pointers CounterSignedBlobs *pCounterSigBlob; //Pointer to array of counter signed blob pointers }; and this is my delete[] bit //Delete all variables used to free memory //------------------------------------------------------------------------------------------------------------ delete[] SignedFileData.psMessage; delete[] SignedFileData.pSignedBlob; delete[] SignedFileData.pCounterSigBlob; SignedFileData.psMessage = NULL; SignedFileData.pSignedBlob = NULL; SignedFileData.pCounterSigBlob = NULL; //------------------------------------------------------------------------------------------------------------
How do you allocate these arrays? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
How do you allocate these arrays? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
im using the new operator i then use memset to zero the memory but i can't see that causing a problem
-
im using the new operator i then use memset to zero the memory but i can't see that causing a problem
Do you pass around the structure so that different copies exist? (like vg as a parameter to some function) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Do you pass around the structure so that different copies exist? (like vg as a parameter to some function) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
I only ever passed a pointer to it to other functions.
-
I only ever passed a pointer to it to other functions.
Then chances are this is an out-of-bounds error. Try for instance doubling the space allocated to see if this masks the error. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Then chances are this is an out-of-bounds error. Try for instance doubling the space allocated to see if this masks the error. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Im Lost How can just passing a pointer to other functions cause an out of bound error Peter
-
Im Lost How can just passing a pointer to other functions cause an out of bound error Peter
Peter Liddle wrote: How can just passing a pointer to other functions cause an out of bound error By having that function do something stupid with the pointer! What Kind of error are you getting when you call
delete[]
? And are you sure that all of the memory being freed withdelete[]
was alocated withnew[]
? Peace! -=- James. "Fat people are hard to kidnap." (Try Check Favorites Sometime!)