···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id: skin_buffer.c 25962 2010-05-12 09:31:40Z jdgordon $
99+ *
1010+ * Copyright (C) 2002 by Linus Nielsen Feltzing
1111+ * Copyright (C) 2009 Jonathan Gordon
1212+ *
1313+ * This program is free software; you can redistribute it and/or
1414+ * modify it under the terms of the GNU General Public License
1515+ * as published by the Free Software Foundation; either version 2
1616+ * of the License, or (at your option) any later version.
1717+ *
1818+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1919+ * KIND, either express or implied.
2020+ *
2121+ ****************************************************************************/
2222+2323+#include <stdio.h>
2424+#include <string.h>
2525+#include <stdlib.h>
2626+2727+#ifdef ROCKBOX
2828+#define SKIN_BUFFER_SIZE (400*1024) /* Excessivly large for now */
2929+static unsigned char buffer[SKIN_BUFFER_SIZE];
3030+static unsigned char *buffer_front = NULL; /* start of the free space,
3131+ increases with allocation*/
3232+static size_t buf_size = SKIN_BUFFER_SIZE;
3333+#endif
3434+3535+void skin_buffer_init(size_t size)
3636+{
3737+#if 0 /* this will go in again later probably */
3838+ if (buffer == NULL)
3939+ {
4040+ buf_size = SKIN_BUFFER_SIZE;/* global_settings.skin_buf_size */
4141+4242+ buffer = buffer_alloc(buf_size);
4343+ buffer_front = buffer;
4444+ buffer_back = bufer + buf_size;
4545+ }
4646+ else
4747+#elif defined(ROCKBOX)
4848+ {
4949+ /* reset the buffer.... */
5050+ buffer_front = buffer;
5151+ //TODO: buf_size = size;
5252+ }
5353+#endif
5454+}
5555+5656+/* Allocate size bytes from the buffer */
5757+void* skin_buffer_alloc(size_t size)
5858+{
5959+ void *retval = NULL;
6060+#ifdef ROCKBOX
6161+ retval = buffer_front;
6262+ buffer_front += size;
6363+ /* 32-bit aligned */
6464+ buffer_front = (void *)(((unsigned long)buffer_front + 3) & ~3);
6565+#else
6666+ retval = malloc(size);
6767+#endif
6868+ return retval;
6969+}
+31
lib/skin_parser/skin_buffer.h
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id: skin_buffer.c 25962 2010-05-12 09:31:40Z jdgordon $
99+ *
1010+ * Copyright (C) 2002 by Linus Nielsen Feltzing
1111+ * Copyright (C) 2009 Jonathan Gordon
1212+ *
1313+ * This program is free software; you can redistribute it and/or
1414+ * modify it under the terms of the GNU General Public License
1515+ * as published by the Free Software Foundation; either version 2
1616+ * of the License, or (at your option) any later version.
1717+ *
1818+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1919+ * KIND, either express or implied.
2020+ *
2121+ ****************************************************************************/
2222+2323+#include <stdio.h>
2424+#include <string.h>
2525+#include <stdlib.h>
2626+#ifndef _SKIN_BUFFFER_H_
2727+#define _SKIN_BUFFFER_H_
2828+void skin_buffer_init(size_t size);
2929+/* Allocate size bytes from the buffer */
3030+void* skin_buffer_alloc(size_t size);
3131+#endif