Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement 'segment_array' that allocates memory using ba_alloc #529

Open
bratpiorka opened this issue Jun 4, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@bratpiorka
Copy link
Contributor

Rationale

It is needed whenever we want to allocate an array (e.g. in memspaces) using ba_alloc with a fixed-sized pool.

API Changes

The API could be something like this:

#define SEGMENT_DECLARE(type, num_elems) struct segment_#type#_#num_elems#_t { \
type elems[num_elems]; \
struct segment_t *next; \
};

#define SEGMENT(type, size) (struct segment_#type#_#num_elems#_t)

void segment_array_create(ba_alloc alloc, size_t segmentSize, size_t numSegments);

#define SEGMENT_CREATE(alloc, type, num_elements) ((SEGMENT(type, num_elements)*) segment_array_create(alloc, sizeof(type) * num_elements + 8, 1));

void segmentArrayDestroy(ba_alloc* alloc);
@bratpiorka bratpiorka added the enhancement New feature or request label Jun 4, 2024
@bratpiorka
Copy link
Contributor Author

@igchor this has been moved from JIRA to Github because of the JIRA cleanup. Can you add more information on why we might need this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant