Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Documentation #9

Open
rafaelspring opened this issue Nov 13, 2024 · 0 comments
Open

Documentation #9

rafaelspring opened this issue Nov 13, 2024 · 0 comments

Comments

@rafaelspring
Copy link

Hello,
this looks like a very interesting project but some documentation would be helpful.
At a minimum it'd be great to know what the main functions parameters do.

Also, just some high level information about how I can understand this library would be nice.
It's not a 1:1 replacement to malloc() as it needs an sm_allocator object. Is it a memory pool? What am I looking at here?

It'd also be nice to know the type of setup that needs to be done to use smmalloc from multiple threads.

Annotating your code example:

// create allocator to handle 16, 32, 48 and 64 allocations (4 buckets, 16Mb each) 
// ==> What do you mean by "16, 32, 48 and 64 allocations" ??
// ==> And does it relate to the parameters passed?
sm_allocator space = _sm_allocator_create(4, (16 * 1024 * 1024));

// allocate 19 bytes with 16 bytes alignment
// ==> What info does the 'space' object hold?
// ==> Is it threadsafe?
// ==> How much memory can I allocate from it?
void* p = _sm_malloc(space, 19, 16);

// free memory
_sm_free(space, p)

// destroy allocator
_sm_allocator_destroy(space);

Thank you

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant