summaryrefslogtreecommitdiff
path: root/lib/skin_parser/skin_buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/skin_parser/skin_buffer.c')
-rw-r--r--lib/skin_parser/skin_buffer.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/skin_parser/skin_buffer.c b/lib/skin_parser/skin_buffer.c
new file mode 100644
index 0000000000..8a5a47ddba
--- /dev/null
+++ b/lib/skin_parser/skin_buffer.c
@@ -0,0 +1,69 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: skin_buffer.c 25962 2010-05-12 09:31:40Z jdgordon $
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 * Copyright (C) 2009 Jonathan Gordon
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include <stdio.h>
24#include <string.h>
25#include <stdlib.h>
26
27#ifdef ROCKBOX
28#define SKIN_BUFFER_SIZE (400*1024) /* Excessivly large for now */
29static unsigned char buffer[SKIN_BUFFER_SIZE];
30static unsigned char *buffer_front = NULL; /* start of the free space,
31 increases with allocation*/
32static size_t buf_size = SKIN_BUFFER_SIZE;
33#endif
34
35void skin_buffer_init(size_t size)
36{
37#if 0 /* this will go in again later probably */
38 if (buffer == NULL)
39 {
40 buf_size = SKIN_BUFFER_SIZE;/* global_settings.skin_buf_size */
41
42 buffer = buffer_alloc(buf_size);
43 buffer_front = buffer;
44 buffer_back = bufer + buf_size;
45 }
46 else
47#elif defined(ROCKBOX)
48 {
49 /* reset the buffer.... */
50 buffer_front = buffer;
51 //TODO: buf_size = size;
52 }
53#endif
54}
55
56/* Allocate size bytes from the buffer */
57void* skin_buffer_alloc(size_t size)
58{
59 void *retval = NULL;
60#ifdef ROCKBOX
61 retval = buffer_front;
62 buffer_front += size;
63 /* 32-bit aligned */
64 buffer_front = (void *)(((unsigned long)buffer_front + 3) & ~3);
65#else
66 retval = malloc(size);
67#endif
68 return retval;
69}