From b2ea95e8d27d8d9fdc5a5422c45218026ad01476 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 17 Jun 2010 07:56:51 +0000 Subject: [PATCH] make the parser slightly more usable for rockbox, move the buffer allocation into the lib (maybe not the best spot?) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26880 a1c6a512-1295-4272-9138-f99709370657 --- lib/skin_parser/Makefile | 2 +- lib/skin_parser/skin_parser.c | 25 +++++-------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/lib/skin_parser/Makefile b/lib/skin_parser/Makefile index 5c1be67578..4026f9e9a9 100644 --- a/lib/skin_parser/Makefile +++ b/lib/skin_parser/Makefile @@ -9,7 +9,7 @@ BUILDDIR ?= . -SRC = skin_parser.c skin_debug.c skin_scan.c tag_table.c +SRC = skin_buffer.c skin_parser.c skin_debug.c skin_scan.c tag_table.c OBJ := $(patsubst %.c,$(BUILDDIR)/%.o,$(SRC)) OUT = $(BUILDDIR)/libskin_parser.a CC = gcc diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 93a71919bf..f7ff4ad693 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -24,19 +24,13 @@ #include #include +#include "skin_buffer.h" #include "skin_parser.h" #include "skin_debug.h" #include "tag_table.h" #include "symbols.h" #include "skin_scan.h" -#ifdef ROCKBOX -/* Declaration of parse tree buffer */ -#define SKIN_MAX_MEMORY (30*1024) -static char skin_parse_tree[SKIN_MAX_MEMORY]; -static char *skin_buffer; -#endif - /* Global variables for the parser */ int skin_line = 0; @@ -66,11 +60,7 @@ struct skin_element* skin_parse(const char* document) struct skin_element** to_write = 0; char* cursor = (char*)document; /*Keeps track of location in the document*/ -#ifdef ROCKBOX - /* FIXME */ - skin_buffer = &skin_parse_tree[0]; -#endif - + skin_line = 1; skin_clear_errors(); @@ -765,8 +755,9 @@ static int skin_parse_conditional(struct skin_element* element, char** document) static int skin_parse_comment(struct skin_element* element, char** document) { char* cursor = *document; +#ifndef ROCKBOX char* text = NULL; - +#endif int length; /* * Finding the index of the ending newline or null-terminator @@ -847,13 +838,7 @@ static struct skin_element* skin_parse_code_as_arg(char** document) /* Memory management */ char* skin_alloc(size_t size) { -#ifdef ROCKBOX - char *retval = skin_buffer; - skin_buffer = (void *)(((unsigned long)skin_buffer + 3) & ~3); - return retval; -#else - return malloc(size); -#endif + return skin_buffer_alloc(size); } struct skin_element* skin_alloc_element()