https://github.com/zyedidia/libboxmap
https://github.com/zyedidia/libboxmap
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zyedidia/libboxmap
- Owner: zyedidia
- Created: 2024-11-20T06:49:27.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-07-24T23:28:59.000Z (6 months ago)
- Last Synced: 2025-07-25T05:08:28.422Z (6 months ago)
- Language: C
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libboxmap
A small library for allocating large chunks of the virtual address space.
# API
```c
struct BoxMapOptions {
// Alignment for allocations inside of regions.
size_t minalign;
// Alignment for regions.
size_t maxalign;
// Size of space to reserve on either end of a region.
size_t guardsize;
};
struct BoxMap;
// boxmap_new creates a new BoxMap structure.
struct BoxMap* boxmap_new(struct BoxMapOptions opts);
// boxmap_delete frees a BoxMap structure.
void boxmap_delete(struct BoxMap* map);
// boxmap_size returns the total size available for allocation in 'map'.
uint64_t boxmap_size(struct BoxMap* map);
// boxmap_active returns the number of active spaces in 'map'.
uint64_t boxmap_active(struct BoxMap* map);
// boxmap_reserve reserves 'size' bytes of space in 'map'. If 'size' is 0, it
// will attempt to reserve as much space as possible. Returns false if an error
// occurred.
bool boxmap_reserve(struct BoxMap* map, size_t size);
// boxmap_addspace adds a new space to 'map' of size 'size'. Returns 0 if an
// error occurred.
uintptr_t boxmap_addspace(struct BoxMap* map, size_t size);
// boxmap_rmspace removes the given space from 'map'.
void boxmap_rmspace(struct BoxMap* map, uintptr_t space, size_t size);
// boxmap_strerror returns a string description when a boxmap function returns
// an error.
char* boxmap_strerror(void);
```