diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-12-19 01:20:10 +0000 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-12-19 01:20:10 +0000 |
commit | 85b0af8123c0eec0d472c304e3fee440beb7d2b9 (patch) | |
tree | 71b509b04f7d1ae6428bff75ced4e004fb2fc089 /src/xine-utils | |
parent | 530ba72be38719c9857afecea9e77fe1c5df3137 (diff) | |
download | xine-lib-85b0af8123c0eec0d472c304e3fee440beb7d2b9.tar.gz xine-lib-85b0af8123c0eec0d472c304e3fee440beb7d2b9.tar.bz2 |
Add and use new functions for malloc+memcpy(+NUL-term) fragments.
Diffstat (limited to 'src/xine-utils')
-rw-r--r-- | src/xine-utils/utils.c | 13 | ||||
-rw-r--r-- | src/xine-utils/xineutils.h | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index d9eb7fb3f..e6e997341 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -286,6 +286,19 @@ void *xine_xmalloc_aligned(size_t alignment, size_t size, void **base) { return ptr; } +void *xine_memdup (const void *src, size_t length) +{ + void *dst = malloc (length); + return xine_fast_memcpy (dst, src, length); +} + +void *xine_memdup0 (const void *src, size_t length) +{ + char *dst = xine_xmalloc (length + 1); + dst[length] = 0; + return xine_fast_memcpy (dst, src, length); +} + #ifdef WIN32 /* * Parse command line with Windows XP syntax and copy the command (argv[0]). diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 4ff87e87c..89c62676b 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -633,6 +633,12 @@ void *xine_xcalloc(size_t nmemb, size_t size) XINE_MALLOC XINE_PROTECTED; void *xine_xmalloc_aligned(size_t alignment, size_t size, void **base) XINE_PROTECTED; /* + * Copy blocks of memory. + */ +void *xine_memdup (const void *src, size_t length) XINE_MALLOC XINE_PROTECTED; +void *xine_memdup0 (const void *src, size_t length) XINE_MALLOC XINE_PROTECTED; + +/* * Get user home directory. */ const char *xine_get_homedir(void) XINE_PROTECTED; |