diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/skin_parser/skin_buffer.c | 13 | ||||
-rw-r--r-- | lib/skin_parser/skin_buffer.h | 4 | ||||
-rw-r--r-- | lib/skin_parser/skin_parser.c | 15 | ||||
-rw-r--r-- | lib/skin_parser/skin_parser.h | 1 |
4 files changed, 23 insertions, 10 deletions
diff --git a/lib/skin_parser/skin_buffer.c b/lib/skin_parser/skin_buffer.c index b0910976e2..05cdc0ce03 100644 --- a/lib/skin_parser/skin_buffer.c +++ b/lib/skin_parser/skin_buffer.c | |||
@@ -56,3 +56,16 @@ void* skin_buffer_alloc(size_t size) | |||
56 | #endif | 56 | #endif |
57 | return retval; | 57 | return retval; |
58 | } | 58 | } |
59 | |||
60 | |||
61 | #ifdef ROCKBOX | ||
62 | /* get the number of bytes currently being used */ | ||
63 | size_t skin_buffer_usage(void) | ||
64 | { | ||
65 | return buffer_front - buffer; | ||
66 | } | ||
67 | size_t skin_buffer_freespace(void) | ||
68 | { | ||
69 | return SKIN_BUFFER_SIZE - skin_buffer_usage(); | ||
70 | } | ||
71 | #endif | ||
diff --git a/lib/skin_parser/skin_buffer.h b/lib/skin_parser/skin_buffer.h index fa8f149c71..ff477da539 100644 --- a/lib/skin_parser/skin_buffer.h +++ b/lib/skin_parser/skin_buffer.h | |||
@@ -28,4 +28,8 @@ | |||
28 | void skin_buffer_init(size_t size); | 28 | void skin_buffer_init(size_t size); |
29 | /* Allocate size bytes from the buffer */ | 29 | /* Allocate size bytes from the buffer */ |
30 | void* skin_buffer_alloc(size_t size); | 30 | void* skin_buffer_alloc(size_t size); |
31 | |||
32 | /* get the number of bytes currently being used */ | ||
33 | size_t skin_buffer_usage(void); | ||
34 | size_t skin_buffer_freespace(void); | ||
31 | #endif | 35 | #endif |
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index f7ff4ad693..9c360231e1 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c | |||
@@ -51,6 +51,8 @@ static int skin_parse_conditional(struct skin_element* element, | |||
51 | static int skin_parse_comment(struct skin_element* element, char** document); | 51 | static int skin_parse_comment(struct skin_element* element, char** document); |
52 | static struct skin_element* skin_parse_code_as_arg(char** document); | 52 | static struct skin_element* skin_parse_code_as_arg(char** document); |
53 | 53 | ||
54 | |||
55 | |||
54 | struct skin_element* skin_parse(const char* document) | 56 | struct skin_element* skin_parse(const char* document) |
55 | { | 57 | { |
56 | 58 | ||
@@ -836,15 +838,10 @@ static struct skin_element* skin_parse_code_as_arg(char** document) | |||
836 | 838 | ||
837 | 839 | ||
838 | /* Memory management */ | 840 | /* Memory management */ |
839 | char* skin_alloc(size_t size) | ||
840 | { | ||
841 | return skin_buffer_alloc(size); | ||
842 | } | ||
843 | |||
844 | struct skin_element* skin_alloc_element() | 841 | struct skin_element* skin_alloc_element() |
845 | { | 842 | { |
846 | struct skin_element* retval = (struct skin_element*) | 843 | struct skin_element* retval = (struct skin_element*) |
847 | skin_alloc(sizeof(struct skin_element)); | 844 | skin_buffer_alloc(sizeof(struct skin_element)); |
848 | retval->type = UNKNOWN; | 845 | retval->type = UNKNOWN; |
849 | retval->next = NULL; | 846 | retval->next = NULL; |
850 | retval->tag = NULL; | 847 | retval->tag = NULL; |
@@ -858,19 +855,19 @@ struct skin_element* skin_alloc_element() | |||
858 | struct skin_tag_parameter* skin_alloc_params(int count) | 855 | struct skin_tag_parameter* skin_alloc_params(int count) |
859 | { | 856 | { |
860 | size_t size = sizeof(struct skin_tag_parameter) * count; | 857 | size_t size = sizeof(struct skin_tag_parameter) * count; |
861 | return (struct skin_tag_parameter*)skin_alloc(size); | 858 | return (struct skin_tag_parameter*)skin_buffer_alloc(size); |
862 | 859 | ||
863 | } | 860 | } |
864 | 861 | ||
865 | char* skin_alloc_string(int length) | 862 | char* skin_alloc_string(int length) |
866 | { | 863 | { |
867 | return (char*)skin_alloc(sizeof(char) * (length + 1)); | 864 | return (char*)skin_buffer_alloc(sizeof(char) * (length + 1)); |
868 | } | 865 | } |
869 | 866 | ||
870 | struct skin_element** skin_alloc_children(int count) | 867 | struct skin_element** skin_alloc_children(int count) |
871 | { | 868 | { |
872 | return (struct skin_element**) | 869 | return (struct skin_element**) |
873 | skin_alloc(sizeof(struct skin_element*) * count); | 870 | skin_buffer_alloc(sizeof(struct skin_element*) * count); |
874 | } | 871 | } |
875 | 872 | ||
876 | void skin_free_tree(struct skin_element* root) | 873 | void skin_free_tree(struct skin_element* root) |
diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h index ec0f3b9bfc..95a22a6d53 100644 --- a/lib/skin_parser/skin_parser.h +++ b/lib/skin_parser/skin_parser.h | |||
@@ -122,7 +122,6 @@ struct skin_element | |||
122 | struct skin_element* skin_parse(const char* document); | 122 | struct skin_element* skin_parse(const char* document); |
123 | 123 | ||
124 | /* Memory management functions */ | 124 | /* Memory management functions */ |
125 | char *skin_alloc(size_t size); | ||
126 | struct skin_element* skin_alloc_element(void); | 125 | struct skin_element* skin_alloc_element(void); |
127 | struct skin_element** skin_alloc_children(int count); | 126 | struct skin_element** skin_alloc_children(int count); |
128 | struct skin_tag_parameter* skin_alloc_params(int count); | 127 | struct skin_tag_parameter* skin_alloc_params(int count); |