Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thehxdev/balloc
Fixed Buffer Memory Allocator in C
https://github.com/thehxdev/balloc
allocator c memory-allocator
Last synced: about 2 months ago
JSON representation
Fixed Buffer Memory Allocator in C
- Host: GitHub
- URL: https://github.com/thehxdev/balloc
- Owner: thehxdev
- License: mit
- Created: 2024-05-09T07:19:11.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-13T07:04:58.000Z (8 months ago)
- Last Synced: 2024-05-13T20:25:11.793Z (8 months ago)
- Topics: allocator, c, memory-allocator
- Language: C
- Homepage:
- Size: 18.6 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fixed Buffer Memory Allocator
My implementation of Fixed Buffer Memory Allocator in C.
## How it works?
This memory allocator designed to minimize the calls to `malloc` and `free` (in general, system calls) because they
tend to be slow. The allocator allocates a fixed size buffer (4096 Bytes by default) and uses that to store data.Take a look at `test/test.c` file to see how to use this memory allocator.
## Public API
This section covers balloc's public API
### Constants
There are 3 constants in `src/balloc.h` file that you can modify.
#### `BALLOC_DEBUG`
Set this constant to `1` to enable logging.#### `BALLOC_PTR_MD`
Set this constant to `1` to store pointers metadata. This will waste a size of `size_t` type for each pointer on the buffer.
But, to do some memory operations safely (since all data lives in a buffer) it's important to know each pointer's size.#### `DEFAULT_BUFF_SIZE`
Default buffer size. (4096 Bytes)---
### Functions
#### `balloc_new`
Create and construct a new fixed buffer allocator with type `BuffAlloc`.#### Other funcitons
Take a look at `src/balloc.h` in `Public API` section for all functions that are available to you.
You can also read `test/test.c` file to see how to use public API and some functions that balloc provides.