aboutsummaryrefslogtreecommitdiff
path: root/py/binary.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-27 12:05:11 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-27 12:05:11 +0000
commit88a9103b3c31a3ecbd70669a53d82dc5a947dfe8 (patch)
tree9d52e53eb1bf7b58bc8f4cd2d5e6aa10d34c8dc9 /py/binary.c
parent30484338092bfaad9f4ecff13b4219d94157fa06 (diff)
py/binary: Make use of MP_ALIGN.
Diffstat (limited to 'py/binary.c')
-rw-r--r--py/binary.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/binary.c b/py/binary.c
index 71ef3f04d..c9ce0585d 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -185,7 +185,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) {
size_t size = mp_binary_get_size(struct_type, val_type, &align);
if (struct_type == '@') {
// Make pointer aligned
- p = (byte*)(((mp_uint_t)p + align - 1) & ~((mp_uint_t)align - 1));
+ p = (byte*)MP_ALIGN(p, (size_t)align);
#if MP_ENDIANNESS_LITTLE
struct_type = '<';
#else
@@ -250,7 +250,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
size_t size = mp_binary_get_size(struct_type, val_type, &align);
if (struct_type == '@') {
// Make pointer aligned
- p = (byte*)(((mp_uint_t)p + align - 1) & ~((mp_uint_t)align - 1));
+ p = (byte*)MP_ALIGN(p, (size_t)align);
if (MP_ENDIANNESS_LITTLE) {
struct_type = '<';
} else {