Re: malloc() implementation



Karsten Jung wrote:
Hello together,

We have to make our own implementation of malloc() under Linux. Does
anybody can give me a hint where to start?

Our implementation should only work under Linux.

Read the glibc code (if "pollution" from LGPL code is not a problem) and ask on a Linux group, remembering that you will have to write your own free and realloc code, and you have to deal with the issue of whether other library routines are calling your malloc or the standard one. Personally I would not bother without a *very* good reason (which might exist).

You can't write a malloc routine in standard C which might be part of why it is in the standard library, hence the suggestion of asking in a Linux group.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
.



Relevant Pages

  • Re: malloc() size problems
    ... I have a strange problem with malloc(). ... images with a variable size, say from 75k to 500k, ... message (heap corruption, or something like this). ... programming in Linux, but the problem persists in windows too. ...
    (comp.lang.c)
  • Re: malloc under linux
    ... standard. ... how malloc behaves under Linux is out of topic here. ... jacob at jacob point remcomp point fr ...
    (comp.lang.c)
  • Re: User implementable standard library functions
    ... and, if from mmap, it is aligned to a page boundary. ... good enough for if running on linux, just have to detect and use. ... on windows, I use malloc. ... pointer to an integer or vice versa is implementation-defined. ...
    (comp.lang.c)
  • Re: [9fans] plan 9 overcommits memory?
    ... when I discovered that Linux was overcommitting memory ... added an optional feature to my portable malloc implementation ... Linux for example, due to it's behavior. ... Mac OS X has many options for testing malloc results as well. ...
    (comp.os.plan9)
  • Re: Alignment of automatic arrays
    ... You've described a malloc() ... I use 32-bit linux at work, ... Try setting -O3 to compile a gcc function where that produces auto-vectorization and data on stack, but with -Os set to compile the function above it in the call stack, or with data allocated by 32-bit standard malloc. ... 50/50 chance of failure on x86_64, ...
    (comp.lang.c)