Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NanXiao/umalloc
A tiny Unix dynamic memory allocator library.
https://github.com/NanXiao/umalloc
Last synced: about 2 months ago
JSON representation
A tiny Unix dynamic memory allocator library.
- Host: GitHub
- URL: https://github.com/NanXiao/umalloc
- Owner: NanXiao
- License: bsd-3-clause
- Created: 2017-09-22T23:36:26.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-10T02:03:02.000Z (almost 7 years ago)
- Last Synced: 2024-06-18T02:35:14.922Z (3 months ago)
- Language: C
- Size: 6.84 KB
- Stars: 63
- Watchers: 5
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# umalloc
A tiny Unix dynamic memory allocator library. The allocated memory is divided into `4` parts:-------------------------------------------------
| | | | |
|chunk_size|head_guard| chunk |tail_guard|
| | | | |
-------------------------------------------------
Besides the allocated memory are initialized to `0`, when free the memory, it will check following cases:(1) Both up and down out-of-bound memory error;
(2) Double-free pointer error.## Usage
$ git clone https://github.com/NanXiao/umalloc.git
$ cd umalloc
$ make && make install## Example:
#include
#include
#include
#include
#includeint main(void)
{
uint32_t size = 1;
for (size = 1; size < UINT32_MAX; size++)
{
printf("size=%" PRIu32 "\n", size);
char *p = umalloc(size);
memset(p, 0xFF, size);
p = urealloc(p, size - 1);
p = urealloc(p, size);
ufree(p);
}
return 0;
}Build and run it:
$ cc -I/usr/local/include -L/usr/local/lib -Wall -o test test.c -lumalloc
$ ./test