brendanashworth / balloc

memory allocation util library for C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

balloc

Build Status

Mostly comprehensive C memory allocation library. Has equivalents for free(3), malloc(3), and realloc(3).

Features

  • Memory safe mode (on by default, -DBALLOC_SAFE) that resets (to NULL) the memory when newly-allocated and free'd, rather than junk memory.
  • Resets free'd pointers, preventing double-free() errors and vulnerabilities.
  • Keeps track of allocated memory, able to be retrieved at any time with ba_size().
  • Errors on a failed allocation, rather than a hard to trace NULL pointer reference.

Documentation

Read through balloc.h for the documentation and forward declarations. When in doubt, read the source code. For examples, take a look at the tests.

Building

Building balloc requires:

  • bash
  • C compiler (gcc by default, change with make CC=...)
  • file archiver (ar by default)
$ make

This will build a shared library file (which can be compiled against) to out/libballoc.a and will then run the tests.

Build shared library

You can specify a location to build the shared library to like so:

$ make LIB_OUT=/my/custom/dir/libballoc.a

Run tests

Tests will be run by the test.sh file. Run tests only like so:

$ make test

License

MIT licensed. Enjoy :)

About

memory allocation util library for C

License:MIT License


Languages

Language:C 87.5%Language:Makefile 8.8%Language:Shell 3.8%