You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Sami Vaarala d52e7c0526 Examples and extras fixes for #if(n)def 8 years ago
..
Makefile Remove DUK_OPT_xxx support from tooling etc 8 years ago
README.rst Add alloc-pool extra with auto pool sizing 8 years ago
duk_alloc_pool.c Add alloc-pool extra with auto pool sizing 8 years ago
duk_alloc_pool.h Examples and extras fixes for #if(n)def 8 years ago
ptrcomp.yaml Add alloc-pool extra with auto pool sizing 8 years ago
ptrcomp_fixup.h Add alloc-pool extra with auto pool sizing 8 years ago
test.c Add alloc-pool extra with auto pool sizing 8 years ago

README.rst

=====================================
Pool allocator for low memory targets
=====================================

A simple pool allocator which satisfies allocations from preallocated pools
containing blocks of a certain size. The caller provides a continuous memory
region and a pool configuration when initializing the allocator.

The pool configuration specifies the block sizes used, and parameters to
control how many entries are allocated for each block size. The parameters
are specified with respect to an arbitrary floating point scaling parameter
``t`` as follows::

bytes = A*t + B
count = floor(bytes / block_size)
= floor((A*t + B) / block_size)

A: constant which indicates how quickly more bytes are assigned for this
block size as the total allocation grows

B: constant which indicates the base allocation for this block size, i.e.
the allocated needed by Duktape initialization

Pool initialization finds the largest floating point ``t`` which still fits in
the memory region provided. Any leftover bytes are sprinkled to the pools to
minimize wasted space.

A pool configuration can be written manually (by trial and error) or using
some automatic tooling such as ``pool_simulator.py``.

When using pointer compression only a single global pool is supported. This
reduces code footprint and is usually sufficient in low memory targets.

Pointer compression functions are defined as inline functions in
``duk_alloc_pool.h`` to allow the compiler to inline pointer compression when
appropriate. As a side effect ``duk_config.h`` must include
``duk_alloc_pool.h`` so that the declarations are visible when compiling
Duktape.