From bf9dd7670673cb5a807f130bdd619bbec2b5620f Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Mon, 16 Jul 2001 18:04:52 +0000 Subject: [PATCH] add method for uint64 type --- src/libFLAC/include/private/memory.h | 1 + src/libFLAC/memory.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/libFLAC/include/private/memory.h b/src/libFLAC/include/private/memory.h index c6e0837c..21730ab8 100644 --- a/src/libFLAC/include/private/memory.h +++ b/src/libFLAC/include/private/memory.h @@ -30,6 +30,7 @@ void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); +FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer); FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer); FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); diff --git a/src/libFLAC/memory.c b/src/libFLAC/memory.c index e2088d0c..213ed52c 100644 --- a/src/libFLAC/memory.c +++ b/src/libFLAC/memory.c @@ -81,6 +81,28 @@ FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint } } +FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer) +{ + FLAC__uint64 *pa, *pu; /* aligned pointer, unaligned pointer */ + + FLAC__ASSERT(elements > 0); + FLAC__ASSERT(0 != unaligned_pointer); + FLAC__ASSERT(0 != aligned_pointer); + FLAC__ASSERT(unaligned_pointer != aligned_pointer); + + pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(FLAC__uint64) * elements, (void*)&pa); + if(0 == pu) { + return false; + } + else { + if(*unaligned_pointer != 0) + free(*unaligned_pointer); + *unaligned_pointer = pu; + *aligned_pointer = pa; + return true; + } +} + FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer) { unsigned *pa, *pu; /* aligned pointer, unaligned pointer */