diff options
Diffstat (limited to 'src/xine-utils')
-rw-r--r-- | src/xine-utils/attributes.h | 28 | ||||
-rw-r--r-- | src/xine-utils/memcpy.c | 6 | ||||
-rw-r--r-- | src/xine-utils/monitor.c | 11 | ||||
-rw-r--r-- | src/xine-utils/utils.c | 21 | ||||
-rw-r--r-- | src/xine-utils/xineutils.h | 8 | ||||
-rw-r--r-- | src/xine-utils/xmllexer.c | 15 | ||||
-rw-r--r-- | src/xine-utils/xmlparser.c | 4 |
7 files changed, 63 insertions, 30 deletions
diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index b533286c8..280fd3685 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -1,8 +1,10 @@ /* * attributes.h * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * Copyright (C) 2001-2007 xine developers * - * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. + * This file was originally part of mpeg2dec, a free MPEG-2 video stream + * decoder. * * mpeg2dec is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,18 +32,6 @@ #define ATTR_ALIGN(align) #endif -/* disable GNU __attribute__ extension, when not compiling with GNU C */ -#if defined(__GNUC__) || defined (__ICC) -#ifndef ATTRIBUTE_PACKED -#define ATTRIBUTE_PACKED 1 -#endif -#else -#undef ATTRIBUTE_PACKED -#ifndef __attribute__ -#define __attribute__(x) /**/ -#endif /* __attribute __*/ -#endif - #ifdef XINE_COMPILE # include "config.h" #endif @@ -81,4 +71,16 @@ # define XINE_FORMAT_PRINTF_ARG(fmt) #endif +#ifdef SUPPORT_ATTRIBUTE_PACKED +# define XINE_PACKED __attribute__((packed)) +#else +# define XINE_PACKED +#endif + +#ifdef SUPPORT_ATTRIBUTE_MALLOC +# define XINE_MALLOC __attribute__((__malloc__)) +#else +# define XINE_MALLOC +#endif + #endif /* ATTRIBUTE_H_ */ diff --git a/src/xine-utils/memcpy.c b/src/xine-utils/memcpy.c index 539f4c8dd..67645081e 100644 --- a/src/xine-utils/memcpy.c +++ b/src/xine-utils/memcpy.c @@ -383,8 +383,8 @@ static void *linux_kernel_memcpy(void *to, const void *from, size_t len) { #endif /* ARCH_X86 */ static struct { - char *name; - void *(* function)(void *to, const void *from, size_t len); + char *const name; + void *(*const function)(void *to, const void *from, size_t len); uint64_t time; /* This type could be used for non-MSC build too! */ @@ -461,7 +461,7 @@ void xine_probe_fast_memcpy(xine_t *xine) char *buf1, *buf2; int i, j, best; int config_flags = -1; - static const char *memcpy_methods[] = { + static const char *const memcpy_methods[] = { "probe", "libc", #if (defined(ARCH_X86) || defined(ARCH_X86_64)) && !defined(_MSC_VER) "kernel", "mmx", "mmxext", "sse", diff --git a/src/xine-utils/monitor.c b/src/xine-utils/monitor.c index 1a348087c..19a9dc977 100644 --- a/src/xine-utils/monitor.c +++ b/src/xine-utils/monitor.c @@ -41,13 +41,10 @@ static long profiler_calls[MAX_ID] ; static const char *profiler_label[MAX_ID] ; void xine_profiler_init () { - int i; - for (i=0; i<MAX_ID; i++) { - profiler_times[i] = 0; - profiler_start[i] = 0; - profiler_calls[i] = 0; - profiler_label[i] = NULL; - } + memset(profiler_times, 0, sizeof(profiler_times)); + memset(profiler_start, 0, sizeof(profiler_start)); + memset(profiler_calls, 0, sizeof(profiler_calls)); + memset(profiler_label, 0, sizeof(profiler_label)); } int xine_profiler_allocate_slot (const char *label) { diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index fa0c11dbe..63c2e2f09 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -256,6 +256,27 @@ void *xine_xmalloc(size_t size) { return ptr; } +/** + * @brief Wrapper around calloc() function. + * @param nmemb Number of elements to allocate + * @param size Size of each element to allocate + * + * This is a simple wrapper around calloc(), the only thing + * it does more than calloc() is outputting an error if + * the calloc fails (returning NULL). + */ +void *xine_xcalloc(size_t nmemb, size_t size) { + void *ptr; + + if((ptr = calloc(nmemb, size)) == NULL) { + fprintf(stderr, "%s: calloc() failed: %s.\n", + __XINE_FUNCTION__, strerror(errno)); + return NULL; + } + + return ptr; +} + void *xine_xmalloc_aligned(size_t alignment, size_t size, void **base) { char *ptr; diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 03c5f689a..0be29ff63 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -624,11 +624,9 @@ void xine_profiler_print_results (void) XINE_PROTECTED; * Allocate and clean memory size_t 'size', then return the pointer * to the allocated memory. */ -#if !defined(__GNUC__) || __GNUC__ < 3 -void *xine_xmalloc(size_t size) XINE_PROTECTED; -#else -void *xine_xmalloc(size_t size) __attribute__ ((__malloc__)) XINE_PROTECTED; -#endif +void *xine_xmalloc(size_t size) XINE_MALLOC XINE_PROTECTED; + +void *xine_xcalloc(size_t nmemb, size_t size) XINE_MALLOC XINE_PROTECTED; /* * Same as above, but memory is aligned to 'alignement'. diff --git a/src/xine-utils/xmllexer.c b/src/xine-utils/xmllexer.c index 575c37611..754a006f9 100644 --- a/src/xine-utils/xmllexer.c +++ b/src/xine-utils/xmllexer.c @@ -120,6 +120,10 @@ int lexer_get_token(char * tok, int tok_size) { state = 7; break; + case '\'': /* " */ + state = 12; + break; + case '-': state = 10; tok[tok_pos] = c; @@ -322,6 +326,17 @@ int lexer_get_token(char * tok, int tok_size) { } break; + /* T_STRING (single quotes) */ + case 12: + tok[tok_pos] = c; + lexbuf_pos++; + if (c == '\'') { /* " */ + tok[tok_pos] = '\0'; /* FIXME */ + return T_STRING; + } + tok_pos++; + break; + /* IDENT */ case 100: switch (c) { diff --git a/src/xine-utils/xmlparser.c b/src/xine-utils/xmlparser.c index 47096705a..363c6381f 100644 --- a/src/xine-utils/xmlparser.c +++ b/src/xine-utils/xmlparser.c @@ -413,7 +413,7 @@ static int xml_parser_get_node (xml_node_t *current_node, char *root_name, int r } break; - /* > expected */ + /* ?> expected */ case 8: switch (res) { case (T_TI_STOP): @@ -425,7 +425,7 @@ static int xml_parser_get_node (xml_node_t *current_node, char *root_name, int r } break; - /* ?> expected */ + /* > expected */ case 9: switch (res) { case (T_M_STOP_1): |