Results 1 to 7 of 7

Thread: how to write malloc function

  1. #1
    Join Date
    Aug 2007
    Location
    SriLanka
    Beans
    385
    Distro
    Ubuntu 12.04 Precise Pangolin

    how to write malloc function

    I'm in big trouble. I want to write malloc() function in language C. I want to write 'new malloc' function it do same thing in original malloc function do. This is my question

    Write your own replacements for the memory allocation/deallocation routines malloc() and free(). Name these two new functions NewMalloc() and NewFree(). These two functions should be implemented in a file called newmalloc.c. Make sure to use the exact spellings as given above for the functions as well as the file. NewMalloc() allocates memory for each call from an array of fixed size. This array is an array of 50,000 characters. All the data structures that you declare to manage this 50,000 bytes memory area must reside within that memory area. The memory allocated using NewMalloc() can be freed with NewFree(). You cannot use malloc() or free() to write these two new functions. If memory cannot be allocated using the available memory a suitable error value must be returned. The funtion prototypes of NewMalloc() and NewFree() should be the same as of malloc() and free().

    This is my original question if anyone give some answer it's great help to me. I want it as soon as posible.

  2. #2
    Join Date
    Oct 2005
    Location
    Wyoming, USA
    Beans
    484
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: how to write malloc function

    Quote Originally Posted by mthalis View Post
    I'm in big trouble. I want to write malloc() function in language C. I want to write 'new malloc' function it do same thing in original malloc function do. This is my question

    Write your own replacements for the memory allocation/deallocation routines malloc() and free(). Name these two new functions NewMalloc() and NewFree(). These two functions should be implemented in a file called newmalloc.c. Make sure to use the exact spellings as given above for the functions as well as the file. NewMalloc() allocates memory for each call from an array of fixed size. This array is an array of 50,000 characters. All the data structures that you declare to manage this 50,000 bytes memory area must reside within that memory area. The memory allocated using NewMalloc() can be freed with NewFree(). You cannot use malloc() or free() to write these two new functions. If memory cannot be allocated using the available memory a suitable error value must be returned. The funtion prototypes of NewMalloc() and NewFree() should be the same as of malloc() and free().

    This is my original question if anyone give some answer it's great help to me. I want it as soon as posible.
    Which class is this for?
    This looks nothing like my signature...
    My Page

  3. #3
    Join Date
    Aug 2007
    Location
    SriLanka
    Beans
    385
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: how to write malloc function

    it header include only <stdio.h> thats what I want but if can't use it you can use anything you want. please send anser less than one hour.

  4. #4
    Join Date
    Feb 2006
    Location
    San José, Costa Rica
    Beans
    456
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: how to write malloc function

    Haha... earn your grade

  5. #5
    Join Date
    Oct 2005
    Location
    Wyoming, USA
    Beans
    484
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: how to write malloc function

    Quote Originally Posted by mthalis View Post
    please send anser less than one hour.
    That's my favorite part!
    This looks nothing like my signature...
    My Page

  6. #6
    Join Date
    Apr 2006
    Location
    in the dark
    Beans
    1,513

    Re: how to write malloc function

    I have an answer


    DO YOUR OWN HOMEWORK
    Imagination is more important than knowledge

  7. #7
    Join Date
    Jan 2005
    Beans
    67

    Re: how to write malloc function

    If you going to try this trick, leasst make sure it doesn't sound like its for homework...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •