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. might be a dumb question...

might be a dumb question...

Scheduled Pinned Locked Moved C / C++ / MFC
questioncom
4 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.
  • L Offline
    L Offline
    l a u r e n
    wrote on last edited by
    #1

    if i calloc() a buffer and write data into it and then later copy other data into it that is shorter than the original data (and zero terminated) will the entire original buffer be freed properly when i call free() on it?


    "there is no spoon"
    biz stuff   about me

    J M 2 Replies Last reply
    0
    • L l a u r e n

      if i calloc() a buffer and write data into it and then later copy other data into it that is shorter than the original data (and zero terminated) will the entire original buffer be freed properly when i call free() on it?


      "there is no spoon"
      biz stuff   about me

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #2

      Yes. calloc(num, size) is just shorthand for memset(malloc(num * size), 0, num * size). -- 20 eyes in my head, they're all the same![^]

      L 1 Reply Last reply
      0
      • L l a u r e n

        if i calloc() a buffer and write data into it and then later copy other data into it that is shorter than the original data (and zero terminated) will the entire original buffer be freed properly when i call free() on it?


        "there is no spoon"
        biz stuff   about me

        M Offline
        M Offline
        Matthew Busche
        wrote on last edited by
        #3

        That is my understanding. It is also my understanding that night will be followed by day in the coming hours. I could be mistaken about one or the other or both, but I'm fairly certain about both. Matt

        1 Reply Last reply
        0
        • J Jorgen Sigvardsson

          Yes. calloc(num, size) is just shorthand for memset(malloc(num * size), 0, num * size). -- 20 eyes in my head, they're all the same![^]

          L Offline
          L Offline
          l a u r e n
          wrote on last edited by
          #4

          thnx guys doh i feel dumb now :rolleyes:


          "there is no spoon"
          biz stuff   about me

          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