summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/buflib.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/buflib.h')
-rw-r--r--apps/plugins/lib/buflib.h58
1 files changed, 0 insertions, 58 deletions
diff --git a/apps/plugins/lib/buflib.h b/apps/plugins/lib/buflib.h
deleted file mode 100644
index 47ad57f526..0000000000
--- a/apps/plugins/lib/buflib.h
+++ /dev/null
@@ -1,58 +0,0 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* This is a memory allocator designed to provide reasonable management of free
11* space and fast access to allocated data. More than one allocator can be used
12* at a time by initializing multiple contexts.
13*
14* Copyright (C) 2009 Andrew Mahone
15*
16* This program is free software; you can redistribute it and/or
17* modify it under the terms of the GNU General Public License
18* as published by the Free Software Foundation; either version 2
19* of the License, or (at your option) any later version.
20*
21* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22* KIND, either express or implied.
23*
24****************************************************************************/
25
26#ifndef _BUFLIB_H_
27#include <plugin.h>
28
29union buflib_data
30{
31 intptr_t val;
32 union buflib_data *ptr;
33};
34
35struct buflib_context
36{
37 union buflib_data *handle_table;
38 union buflib_data *first_free_handle;
39 union buflib_data *last_handle;
40 union buflib_data *first_free_block;
41 union buflib_data *buf_start;
42 union buflib_data *alloc_end;
43 bool compact;
44};
45
46void buflib_init(struct buflib_context *context, void *buf, size_t size);
47int buflib_alloc(struct buflib_context *context, size_t size);
48void buflib_free(struct buflib_context *context, int handle);
49void* buflib_buffer_out(struct buflib_context *ctx, size_t *size);
50void buflib_buffer_in(struct buflib_context *ctx, int size);
51
52
53
54static inline void* buflib_get_data(struct buflib_context *context, int handle)
55{
56 return (void*)(context->handle_table[-handle].ptr);
57}
58#endif