mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
buflib: add pin/unpin operation
An allocation is pinned by calling buflib_pin() to up its pin count. The pin count is like a reference count: when above 0, buflib won't move the allocation and won't call its move callbacks. This makes it safe to hold the pointer returned by buflib_get_data() across yields or allocations. Note that pinned allocations can still shrink because there are some use cases where this would be valid, if buffer users coordinate with the shrink callback. Change-Id: I0d0c2a8ac7d891d3ad6b3d0eb80c5b5a1b4b9a9d
This commit is contained in:
parent
ecfec3e9bf
commit
f47aa584a8
4 changed files with 79 additions and 4 deletions
|
@ -104,6 +104,21 @@ bool core_shrink(int handle, void* new_start, size_t new_size)
|
|||
return buflib_shrink(&core_ctx, handle, new_start, new_size);
|
||||
}
|
||||
|
||||
void core_pin(int handle)
|
||||
{
|
||||
buflib_pin(&core_ctx, handle);
|
||||
}
|
||||
|
||||
void core_unpin(int handle)
|
||||
{
|
||||
buflib_unpin(&core_ctx, handle);
|
||||
}
|
||||
|
||||
unsigned core_pin_count(int handle)
|
||||
{
|
||||
return buflib_pin_count(&core_ctx, handle);
|
||||
}
|
||||
|
||||
const char* core_get_name(int handle)
|
||||
{
|
||||
const char *name = buflib_get_name(&core_ctx, handle);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue