diff options
Diffstat (limited to 'src/xine-utils')
| -rw-r--r-- | src/xine-utils/attributes.h | 38 | ||||
| -rw-r--r-- | src/xine-utils/monitor.c | 10 | ||||
| -rw-r--r-- | src/xine-utils/utils.c | 20 | ||||
| -rw-r--r-- | src/xine-utils/xineutils.h | 2 | ||||
| -rw-r--r-- | src/xine-utils/xmllexer.c | 3 |
5 files changed, 51 insertions, 22 deletions
diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index 3d6e66359..29bb9f28f 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -32,20 +32,28 @@ #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 "configure.h" +#else +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95 ) +# define SUPPORT_ATTRIBUTE_PACKED 1 +# endif + +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3 ) +# define SUPPORT_ATTRIBUTE_DEPRECATED 1 +# define SUPPORT_ATTRIBUTE_FORMAT 1 +# define SUPPORT_ATTRIBUTE_FORMAT_ARG 1 +# define SUPPORT_ATTRIBUTE_MALLOC 1 +# define SUPPORT_ATTRIBUTE_UNUSED 1 +# endif + +# if __GNUC__ >= 4 +# define SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT 1 +# if __ELF__ +# define SUPPORT_ATTRIBUTE_VISIBILITY_PROTECTED 1 +# endif +# define SUPPORT_ATTRIBUTE_SENTINEL 1 +# endif #endif /* Export protected only for libxine functions */ @@ -95,4 +103,10 @@ # define XINE_MALLOC #endif +#ifdef SUPPORT_ATTRIBUTE_PACKED +# define XINE_PACKED __attribute__((__packed__)) +#else +# define XINE_PACKED +#endif + #endif /* ATTRIBUTE_H_ */ diff --git a/src/xine-utils/monitor.c b/src/xine-utils/monitor.c index fb323055c..301d6c22f 100644 --- a/src/xine-utils/monitor.c +++ b/src/xine-utils/monitor.c @@ -39,12 +39,10 @@ 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 48ceef688..4085d65ee 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -236,7 +236,25 @@ static const lang_locale_t lang_locales[] = { { NULL, NULL, NULL, NULL } }; - +/** + * @brief Allocate and clean memory size_t 'size', then return the + * pointer to the allocated memory. + * @param size Size of the memory area to allocate. + * + * @return A pointer to the allocated memory area, or NULL in case of + * error. + * + * The behaviour of this function differs from standard malloc() as + * xine_xmalloc(0) will not return a NULL pointer, but rather a + * pointer to a memory area of size 1 byte. + * + * The NULL value is only ever returned in case of an error in + * malloc(), and is reported to stderr stream. + * + * @deprecated This function has been deprecated, as the behaviour of + * allocating a 1 byte memory area on zero size is almost + * never desired, and the function is thus mostly misused. + */ void *xine_xmalloc(size_t size) { void *ptr; diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 2099bf7f3..89aff96bf 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -621,7 +621,7 @@ void xine_profiler_print_results (void) XINE_PROTECTED; * Allocate and clean memory size_t 'size', then return the pointer * to the allocated memory. */ -void *xine_xmalloc(size_t size) XINE_MALLOC XINE_PROTECTED; +void *xine_xmalloc(size_t size) XINE_MALLOC XINE_DEPRECATED 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 09e5a5e24..7da4cc59b 100644 --- a/src/xine-utils/xmllexer.c +++ b/src/xine-utils/xmllexer.c @@ -29,7 +29,6 @@ #include "xineutils.h" #else #define lprintf(...) -#define xine_xmalloc malloc #endif #include "xmllexer.h" #include <stdio.h> @@ -534,7 +533,7 @@ static struct { char *lexer_decode_entities (const char *tok) { - char *buf = xine_xmalloc (strlen (tok) + 1); + char *buf = calloc (strlen (tok) + 1, sizeof(char)); char *bp = buf; char c; |
