gpgscm: Use a static pool of cells for small integers.
authorJustus Winter <justus@g10code.com>
Wed, 16 Nov 2016 10:29:34 +0000 (11:29 +0100)
committerJustus Winter <justus@g10code.com>
Tue, 22 Nov 2016 11:09:47 +0000 (12:09 +0100)
commit66834eb838a8892d088f6b7332084a64d9f15008
tree2e37430f40bd9364c05cbd99daebbb9cebc28391
parent893a3f7fb46021961914a8acdf1292a80e3eba93
gpgscm: Use a static pool of cells for small integers.

* tests/gpgscm/scheme-private.h (struct scheme): New fields for the
static integer cells.
* tests/gpgscm/scheme.c (_alloc_cellseg): New function.
(alloc_cellseg): Use the new function.
(MAX_SMALL_INTEGER): New macro.
(initialize_small_integers): New function.
(mk_small_integer): Likewise.
(mk_integer): Return a small integer if possible.
(_s_return): Do not free 'op' if it is a small integer.
(s_save): Use a small integer to box the opcode.
(scheme_init_custom_alloc): Initialize small integers.
(scheme_deinit): Free chunk of small integers.
* tests/gpgscm/scheme.h (USE_SMALL_INTEGERS): New macro.

Signed-off-by: Justus Winter <justus@g10code.com>
tests/gpgscm/scheme-private.h
tests/gpgscm/scheme.c
tests/gpgscm/scheme.h