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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. free memory

free memory

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
2 Posts 2 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.
  • S Offline
    S Offline
    Sirrius
    wrote on last edited by
    #1

    Is there a way to free memory from struct?

    L 1 Reply Last reply
    0
    • S Sirrius

      Is there a way to free memory from struct?

      L Offline
      L Offline
      Larry J Siddens
      wrote on last edited by
      #2

      Not sure what your asking... If you allocated memory with "new", then use "delete" and set the pointer to NULL. If you did it with "malloc", then use "free" and set the pointer. What you could do, is create a destructor for a struct and clean up there. Example: struct Stuff { Stuff() { p = NULL, i = 0; } ~Stuff() { delete [] p; p = NULL; } int i; char* p; }; using: { Stuff x; x.p = new char[10]; ASSERT( x.p ); x.i = 10; < other usage > } // cleanup, item will be destroyed. Larry J. Siddens Cornerstone Communications TAME THE DOCUMENT MONSTER www.unifier.biz

      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