could anyone please give me a "plug-in" malloc AND
could anyone please give me a "plug-in" malloc AND
I have tried at least 14 times to make a malloc and have looked at other code but it is very confusing
I got a page allocator so no worries there(that seems to be what everyone leads me to) just i can not figure out how to make a malloc with a free
I got a page allocator so no worries there(that seems to be what everyone leads me to) just i can not figure out how to make a malloc with a free
Re:could anyone please give me a "plug-in" malloc
You could always have a look at mine: http://www.djm.co.za/liballoc/
It's good enough to run firefox, openoffice, etc...and you just need to implement 4 functions and it will work in your system.
It's good enough to run firefox, openoffice, etc...and you just need to implement 4 functions and it will work in your system.
Re:could anyone please give me a "plug-in" malloc
There are hundreds of these things. For my kernel, kalloc() and kfree() are wrappers around bget. Other systems you might try are Doug Lea's malloc (dlmalloc) and the allocator in PDCLib. Take a look around, decide which one suits you best rather than jumping on the first.
Re:could anyone please give me a "plug-in" malloc
@durand
I haven't got it all implemented yet but your malloc and stuff seems to be very good thanks so much
edit:
liballoc works great! thanks again durand
plus thanks to using it i have discovered a big problem in my page allocator when allocating multiple pages >:( but anyway workign on getting that fixed now
I haven't got it all implemented yet but your malloc and stuff seems to be very good thanks so much
edit:
liballoc works great! thanks again durand
plus thanks to using it i have discovered a big problem in my page allocator when allocating multiple pages >:( but anyway workign on getting that fixed now
Re:could anyone please give me a "plug-in" malloc
Good! I haven't had any feedback previously about liballoc but I hope it was easy to implement, clear and stuff. I've tried to make it so...
Re:could anyone please give me a "plug-in" malloc
Wow that's a pretty looking allocator, I'll try to implement it into my OS tomorrow. I'll post results. (Although don't know what good they'll be, not like I have a firefox just lying around in my OS)
Re:could anyone please give me a "plug-in" malloc
Durand: your liballoc page says you don't know why people want 4 byte aligned allocations?
Well, they want that because it gives you 2 bits in each pointer for all kinds of h4x0ring (like dynamic typing), and because 4 byte aligned pointers are faster anyway. There are probably a few more reasons that I forgot.
Well, they want that because it gives you 2 bits in each pointer for all kinds of h4x0ring (like dynamic typing), and because 4 byte aligned pointers are faster anyway. There are probably a few more reasons that I forgot.
Re:could anyone please give me a "plug-in" malloc
Thanks, Mystran. I had to search the gtk source code to find out that it required aligned memory. It just seemed a little odd to me because running an application based on gtk then required a malloc/free implementation that knew to return aligned pointers and I wasn't aware that the standard ones generally did...
Re:could anyone please give me a "plug-in" malloc
Actually, malloc aligning to only 4 bytes can be a pain. You take hit on performance if your doubles aren't aligned to 8 bytes. But that's not even bad. You need to use special unaligned moves if you load SSE registers from unaligned locations, and the alignment requirement is 16 bytes. Guess what? The unaligned move is so slow that you actually lose most of the benefits of SSE.
Technically, I believe malloc is supposed to return "suitably aligned" pointers, and whether or not you consider performance hits to be unsuitable, is a matter of opinion.
Ofcourse most of the time one relies on certain alignment, one should use something like posix_memalign instead. But malloc() exists everywhere...
Technically, I believe malloc is supposed to return "suitably aligned" pointers, and whether or not you consider performance hits to be unsuitable, is a matter of opinion.
Ofcourse most of the time one relies on certain alignment, one should use something like posix_memalign instead. But malloc() exists everywhere...
Re:could anyone please give me a "plug-in" malloc
btw, posix_memalign() manual on my Linux box says:
Code: Select all
GNU libc malloc() always returns 8-byte aligned memory addresses, so these
routines are only needed if you require larger alignment values.