summaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2021-08-17 19:32:12 -0700
committerVito Caputo <vcaputo@pengaru.com>2021-08-17 19:42:06 -0700
commit22ea32f0f945509888a3d0d5167b5d4ed001a3d9 (patch)
treee43ed439c7372eb9cde08b4647cf58456c84cfc3 /example.c
parent070e8c57d5829e9b429f698c329a6d0b0d4d071c (diff)
thunk: introduce thunk_t.free and thunk_free()
While it was convenient to support bare libc free()ing of thunks wherever appropriate, it prevented any form of caching thunk encapsulating environments. This commit introduces thunk_free() for freeing thunk_t instances, and adds a .free() member to the thunk for registering a thunk-specific free method. For plain thunk instantiating, where the environment size is known and fixed for a given thunk, a very simple free list has been added. This added a free_next pointer to the thunk's environment struct, and a thunk-specific free method putting the instance's environment back on the thunk-specific free list. No shrinking is ever done currently, and there's never cleanup of any of this, it's assumed these will be relatively bounded, leveling off at a high watermark, and simply abandoned at process exit for now. For split allocated-initialized thunk instances, no caching is attempted for now. This could be trivially improved at least for non-payload-utilizing cases, as these would be the same size as the plain instantiated thunks so they could just use the same free lists. For the payload-utilizing cases it'd be more tricky, in the interests of simplicity for now, all the split cases just use malloc()+free() as before, but via the thunk_t.free() method. This commit should already significantly reduce the amount of malloc() and free() in most cases.
Diffstat (limited to 'example.c')
0 files changed, 0 insertions, 0 deletions
© All Rights Reserved