diff options
| author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-04-14 17:19:44 +0100 |
|---|---|---|
| committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-04-14 17:19:44 +0100 |
| commit | 2339bb34dc3fcc155a04abda51df9fa00732df93 (patch) | |
| tree | 1832d05244d55417fb3505263af74c238ec3c2a2 /src/xine-utils | |
| parent | 1860c0e221f617406df80b0d35d22462dbcb9055 (diff) | |
| parent | dc36f8d045cf4f723c44766f44c92e1810e37f4f (diff) | |
| download | xine-lib-2339bb34dc3fcc155a04abda51df9fa00732df93.tar.gz xine-lib-2339bb34dc3fcc155a04abda51df9fa00732df93.tar.bz2 | |
Merge changes.
Diffstat (limited to 'src/xine-utils')
| -rw-r--r-- | src/xine-utils/attributes.h | 12 | ||||
| -rw-r--r-- | src/xine-utils/memcpy.c | 6 | ||||
| -rw-r--r-- | src/xine-utils/utils.c | 21 | ||||
| -rw-r--r-- | src/xine-utils/xineutils.h | 8 |
4 files changed, 39 insertions, 8 deletions
diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index 27c6fc5bc..80bcadd7f 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -69,4 +69,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/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'. |
