The Bunny Allocator module reserve at startup a specific amount of memory
and organize memory allocations requested by its function inside.
The Bunny Allocator module ensure that you do not consume too much memory
and that this memory is stable.
The allocator module header is lapin/allocator.h
Description
  This macro enforces the use of the bunny allocator module by
transforming calls to malloc, calloc, realloc or free to bunny equivalent.
INDEX
Description
  This macro can be used in two different fashion:
-
At libray compile time: it disables inside the library itself
any call to the bunny allocator, binding it to the system allocator.
-
At your compile time: it transforms calls to bunny allocator
functions to regular allocator ones.
INDEX
Description
  Reserve the sent amount of bytes and return a pointer to it.
If there is a not enough memory available, the function returns
NULL.
The returned memory space must be freed with
bunny_free.
Parameters
-
size_t size:
  The amount of bytes to reserve.
Return value
-
On success, the function returns the address of the first
byte of the allocated data chunk.
-
On failure, it returns NULL.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "allocator" label.
Additional informations
When compiling LibLapin:
INDEX
Description
  Release the sent memory space so it is made available for later.
Additional informations
When compiling LibLapin:
INDEX
Description
  Reserve memory space for an array of nmemb elements of size bytes each
and returns a pointer to the allocated memory first byte.
The memory is set to zero.
If there is a not enough memory available, the function returns
NULL.
The returned memory space must be freed with
bunny_free.
Parameters
-
size_t nmemb:
  The length of the returned array in case.
-
size_t size:
  The length of a single case in byte.
Return value
-
On success, the function returns the address of the first
byte of the allocated data chunk.
-
On failure, it returns NULL.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "allocator" label.
Additional informations
When compiling LibLapin:
INDEX
Description
  Change the size of the sent memory block to
size byte. If the
new size is smaller than the old one, the sent pointer will be returned
after changing its
metadatas.
If the new size is larger, the returned pointer may be different from
the sent one and the additionnal space will not be initialized.
If
size is equal to zero, the sent pointer will be freed.
If
ptr is
NULL and
size not zero, a memory space is allocated.
The returned memory space must be freed with
bunny_free.
Parameters
-
void *ptr:
  The memory space to reallocate.
-
size_t size:
  The new size of the memory space.
Return value
-
On success, the function returns the address of the first
byte of the allocated data chunk.
-
On failure, it returns NULL. The sent memory space is untouched.
Additional informations
When compiling LibLapin:
INDEX
Description
  This function allows you to ask a memory checkup at the end of your program.
The amount of asked bytes, of chunks, how many of them remains, etc.
It also makes a memory check that will make your program crash if some invalid
writes occured during the execution.
Parameters
-
bool chk:
  Activate or deactivate the memory check.
INDEX
Description
  This function can only be called efficiently before any allocation
made by the bunny library. It allows you to define a maximum heap size.
When the allocated memory reach this size, then allocation functions managed by
the bunny library will start to fail.
By default, it is 20MB.
Parameters
-
size_t bytes:
  The maximum size of the heap.
INDEX