[haiku-gsoc] Re: Implementation Queries

  • From: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Fri, 30 Jun 2017 07:11:02 +0200

On Thu, Jun 29, 2017 at 10:26:57PM +0530, Vivek Roy wrote:

What I read about heap_init() is that after a heap_init using normal
mallocs will allocate memory on the heap. I do not want this behaviour. For
example I have done a heap_init() in linux/slab.h. So every malloc which
will be called after that will use up the heap space. I do not want that.
But all the mallocs inside linux/slab.h should be done on the heap. How do
I get such results? guarded_heap ?

You just rename the malloc() function in the bootloader heap
implementation (to my_malloc or whatever), so that it doesn't conflict
with the existing malloc. There is nothing magic happening in heap_int
which changes how malloc() behaves, the heap just happens to define a
function named malloc.

Then you call my_malloc where you want/need to use this heap. In our
case, maybe the function should be named kmalloc directly, and accept
flags.

-- 
Adrien.

Other related posts: