Extend buflib to support shifting space out off the buffer for other use, and returning space to the buffer.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20952 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andrew Mahone 2009-05-16 00:45:08 +00:00
parent d59bff092d
commit c909878f94
2 changed files with 53 additions and 0 deletions

View file

@ -38,6 +38,7 @@ struct buflib_context
union buflib_data *first_free_handle;
union buflib_data *last_handle;
union buflib_data *first_free_block;
union buflib_data *buf_start;
union buflib_data *alloc_end;
bool compact;
};
@ -45,6 +46,10 @@ struct buflib_context
void buflib_init(struct buflib_context *context, void *buf, size_t size);
int buflib_alloc(struct buflib_context *context, size_t size);
void buflib_free(struct buflib_context *context, int handle);
void* buflib_buffer_out(struct buflib_context *ctx, size_t *size);
void buflib_buffer_in(struct buflib_context *ctx, int size);
/* always_inline is due to this not getting inlined when not optimizing, which
* leads to an unresolved reference since it doesn't exist as a non-inline