Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Pointers

Pointers

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresperformancehelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Peter Liddle
    wrote on last edited by
    #1

    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; //------------------------------------------------------------------------------------------------------------

    J 1 Reply Last reply
    0
    • P Peter Liddle

      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; //------------------------------------------------------------------------------------------------------------

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      How do you allocate these arrays? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      P 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        How do you allocate these arrays? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        P Offline
        P Offline
        Peter Liddle
        wrote on last edited by
        #3

        im using the new operator i then use memset to zero the memory but i can't see that causing a problem

        J 1 Reply Last reply
        0
        • P Peter Liddle

          im using the new operator i then use memset to zero the memory but i can't see that causing a problem

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          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

          P 1 Reply Last reply
          0
          • J Joaquin M Lopez Munoz

            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

            P Offline
            P Offline
            Peter Liddle
            wrote on last edited by
            #5

            I only ever passed a pointer to it to other functions.

            J 1 Reply Last reply
            0
            • P Peter Liddle

              I only ever passed a pointer to it to other functions.

              J Offline
              J Offline
              Joaquin M Lopez Munoz
              wrote on last edited by
              #6

              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

              P 1 Reply Last reply
              0
              • J Joaquin M Lopez Munoz

                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

                P Offline
                P Offline
                Peter Liddle
                wrote on last edited by
                #7

                Im Lost How can just passing a pointer to other functions cause an out of bound error Peter

                J 1 Reply Last reply
                0
                • P Peter Liddle

                  Im Lost How can just passing a pointer to other functions cause an out of bound error Peter

                  J Offline
                  J Offline
                  James R Twine
                  wrote on last edited by
                  #8

                  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 with delete[] was alocated with new[]?    Peace! -=- James. "Fat people are hard to kidnap." (Try Check Favorites Sometime!)

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups