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. MALLOC FUNCTION IMPLEMENTATION

MALLOC FUNCTION IMPLEMENTATION

Scheduled Pinned Locked Moved C / C++ / MFC
c++
4 Posts 4 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.
  • U Offline
    U Offline
    User 11508089
    wrote on last edited by
    #1

    SIR, I want to define my own malloc function in c++ using new operator..

    P J J 3 Replies Last reply
    0
    • U User 11508089

      SIR, I want to define my own malloc function in c++ using new operator..

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Thanks for the warning. Good luck.

      1 Reply Last reply
      0
      • U User 11508089

        SIR, I want to define my own malloc function in c++ using new operator..

        J Offline
        J Offline
        jeron1
        wrote on last edited by
        #3

        and the question is?

        "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst

        1 Reply Last reply
        0
        • U User 11508089

          SIR, I want to define my own malloc function in c++ using new operator..

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          A very simple and realistically non-worthwhile implementation is simple. Your malloc calls new with an byte array. Then your free, which you would also implement would use delete to delete the array. If you want a learning experience however then you should do the following in the specified order. 1. Learn what stack and list are and how to implement them. 2. Specifically learn how to implement them using sequential memory and not just pointers. 3. Learn how malloc is generally implemented. You will need substantial understanding of 1/2 to understand this. 4. Implement your own heap management. (Which you will understand after doing 1/2/3.)

          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