summaryrefslogtreecommitdiff
path: root/src/xine-utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-utils')
-rw-r--r--src/xine-utils/attributes.h23
-rw-r--r--src/xine-utils/list.c2
-rw-r--r--src/xine-utils/monitor.c10
-rw-r--r--src/xine-utils/utils.c22
-rw-r--r--src/xine-utils/xineutils.h2
-rw-r--r--src/xine-utils/xmllexer.c3
-rw-r--r--src/xine-utils/xmlparser.c3
7 files changed, 38 insertions, 27 deletions
diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h
index cb861303d..29bb9f28f 100644
--- a/src/xine-utils/attributes.h
+++ b/src/xine-utils/attributes.h
@@ -32,27 +32,18 @@
#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_PACKED 1
# define SUPPORT_ATTRIBUTE_UNUSED 1
# endif
@@ -112,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/list.c b/src/xine-utils/list.c
index 65bdaec26..b157bda3f 100644
--- a/src/xine-utils/list.c
+++ b/src/xine-utils/list.c
@@ -69,7 +69,7 @@ struct xine_list_s {
*/
static xine_list_chunk_t *xine_list_alloc_chunk(size_t size) {
xine_list_chunk_t *new_chunk;
- size_t chunk_mem_size;;
+ size_t chunk_mem_size;
chunk_mem_size = sizeof(xine_list_chunk_t);
chunk_mem_size += sizeof(xine_list_elem_t) * size;
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..9f5d122cb 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;
@@ -507,7 +525,7 @@ void xine_hexdump (const char *buf, int length) {
static const lang_locale_t *_get_first_lang_locale(const char *lcal) {
const lang_locale_t *llocale;
- int lang_len;
+ size_t lang_len;
char *mod;
if(lcal && *lcal) {
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;
diff --git a/src/xine-utils/xmlparser.c b/src/xine-utils/xmlparser.c
index 426643708..2922135e2 100644
--- a/src/xine-utils/xmlparser.c
+++ b/src/xine-utils/xmlparser.c
@@ -597,11 +597,10 @@ static void xml_parser_dump_node (const xml_node_t *node, int indent) {
xml_property_t *p;
xml_node_t *n;
- int l;
printf ("%*s<%s ", indent, "", node->name);
- l = strlen (node->name);
+ size_t l = strlen (node->name);
p = node->props;
while (p) {