Index of /rez/jalloc

[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[   ]Makefile06-Nov-2008 20:45 83  
[TXT]README.html06-Nov-2008 21:01 1.1K 
[TXT]jalloc.c06-Nov-2008 20:59 10K 
[TXT]jalloc.h06-Nov-2008 20:48 755  
[   ]jalloc.tar.gz06-Nov-2008 20:59 13K 
[TXT]main.c03-Sep-2008 20:41 134  

jalloc is a malloc replacement that I wrote for an embedded platform for a very particular application. 
As such it is unsuitable for your needs. Feel free to use it!

I can't remember how it works, but it seems to. I have vague memories of representing blocks of memory as 
bits in a bitmap and using lookup tables to find free regions of appropriate sizes.

To set up a new heap (a chunk of memory from which you can allocate from), use:
	
	myHeap = new_heap (SIZE, BLOCK_SIZE);

In a very non-thread-safe fashion, jalloc keeps track of your current heap and subsequent calls will act 
on the current heap. To alloc memory, substitute 'm' for 'j':

	void *p = jalloc(size_t);

To switch your current heap, use:

	set_arena(myOtherHeap);

You can also save and load heaps to disk. Nice.

In embedded applications you will want to replace the call to malloc in new_heap (jalloc.c:204 and jalloc.c:210) 
with pointers to space in your device memory.

For a short time only, jalloc comes with some other features like jstrcmp! 

Download here

Josh Reich
i2pi.com