]> git.ipfire.org Git - thirdparty/git.git/commit - mem-pool.h
mem-pool: add life cycle management functions
authorJameson Miller <jamill@microsoft.com>
Mon, 2 Jul 2018 19:49:34 +0000 (19:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jul 2018 17:58:27 +0000 (10:58 -0700)
commit158dfeff3dc1d155b84e68b265a9b6c265717e1e
treebc4f3dee7fa51f28ea50645d59668a59799c2899
parent8fb8e3f63654df20926f665486d2edea2fff0243
mem-pool: add life cycle management functions

Add initialization and discard functions to mem_pool type. As the
memory allocated by mem_pool can now be freed, we also track the large
allocations.

If the there are existing mp_blocks in the mem_poo's linked list of
mp_blocksl, then the mp_block for a large allocation is inserted
behind the head block. This is because only the head mp_block is considered
when searching for availble space. This results in the following
desirable properties:

1) The mp_block allocated for the large request will not be included
not included in the search for available in future requests, the large
mp_block is sized for the specific request and does not contain any
spare space.

2) The head mp_block will not bumped from considation for future
memory requests just because a request for a large chunk of memory
came in.

These changes are in preparation for a future commit that will utilize
creating and discarding memory pool.

Signed-off-by: Jameson Miller <jamill@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mem-pool.c
mem-pool.h