Skip to content

Documentation #9

Description

@rafaelspring

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions