summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-06-17 08:36:28 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-06-17 08:36:28 +0000
commitdb658d98401d23957c8fe88b4bd96ab184f0ffef (patch)
treec24bd15ecad59c49d198b9f9af1b2648beabc164
parentb2ea95e8d27d8d9fdc5a5422c45218026ad01476 (diff)
downloadrockbox-db658d98401d23957c8fe88b4bd96ab184f0ffef.tar.gz
rockbox-db658d98401d23957c8fe88b4bd96ab184f0ffef.zip
woops, forgot to add these
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26882 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--lib/skin_parser/skin_buffer.c69
-rw-r--r--lib/skin_parser/skin_buffer.h31
2 files changed, 100 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}
diff --git a/lib/skin_parser/skin_buffer.h b/lib/skin_parser/skin_buffer.h
new file mode 100644
index 0000000000..fa8f149c71
--- /dev/null
+++ b/lib/skin_parser/skin_buffer.h
@@ -0,0 +1,31 @@
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#ifndef _SKIN_BUFFFER_H_
27#define _SKIN_BUFFFER_H_
28void skin_buffer_init(size_t size);
29/* Allocate size bytes from the buffer */
30void* skin_buffer_alloc(size_t size);
31#endif