Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Strogin
flac
Commits
7cbecbae
Commit
7cbecbae
authored
Mar 07, 2014
by
Fengwei Yin
Committed by
Erik de Castro Lopo
Mar 14, 2014
Browse files
Using uintptr_t to simplify pointer handling a little bit
Signed-off-by:
Erik de Castro Lopo
<
erikd@mega-nerd.com
>
parent
163b7340
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libFLAC/memory.c
View file @
7cbecbae
...
...
@@ -34,6 +34,8 @@
# include <config.h>
#endif
#include
<stdint.h>
#include
"private/memory.h"
#include
"FLAC/assert.h"
#include
"share/alloc.h"
...
...
@@ -46,25 +48,8 @@ void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address)
#ifdef FLAC__ALIGN_MALLOC_DATA
/* align on 32-byte (256-bit) boundary */
x
=
safe_malloc_add_2op_
(
bytes
,
/*+*/
31
);
#ifdef SIZEOF_VOIDP
#if SIZEOF_VOIDP == 4
/* could do *aligned_address = x + ((unsigned) (32 - (((unsigned)x) & 31))) & 31; */
*
aligned_address
=
(
void
*
)(((
unsigned
)
x
+
31
)
&
-
32
);
#elif SIZEOF_VOIDP == 8
*
aligned_address
=
(
void
*
)(((
FLAC__uint64
)
x
+
31
)
&
(
FLAC__uint64
)(
-
((
FLAC__int64
)
32
)));
#else
# error Unsupported sizeof(void*)
#endif
#else
/* there's got to be a better way to do this right for all archs */
if
(
sizeof
(
void
*
)
==
sizeof
(
unsigned
))
*
aligned_address
=
(
void
*
)(((
unsigned
)
x
+
31
)
&
-
32
);
else
if
(
sizeof
(
void
*
)
==
sizeof
(
FLAC__uint64
))
*
aligned_address
=
(
void
*
)(((
FLAC__uint64
)
x
+
31
)
&
(
FLAC__uint64
)(
-
((
FLAC__int64
)
32
)));
else
return
0
;
#endif
x
=
safe_malloc_add_2op_
(
bytes
,
/*+*/
31L
);
*
aligned_address
=
(
void
*
)(((
uintptr_t
)
x
+
31L
)
&
-
32L
);
#else
x
=
safe_malloc_
(
bytes
);
*
aligned_address
=
x
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment