summaryrefslogtreecommitdiff
path: root/py/binary.c
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-09-14 10:44:31 -0400
committerLucian Copeland <hierophect@gmail.com>2020-09-14 10:44:31 -0400
commitecc219fe504f348d5dceb13b0a12d04d1c858781 (patch)
tree3e6d79d558e821e3daac90b711275be5c0153015 /py/binary.c
parentf95ad7b27c040e54daeb4c71d6bb6c35844be66e (diff)
parent94e261370b4ffc7739d6e3e0ca99db9f36f3027b (diff)
Merge remote-tracking branch 'upstream/main' into esp32-displayio-fix
Diffstat (limited to 'py/binary.c')
-rw-r--r--py/binary.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/py/binary.c b/py/binary.c
index cd0f1aa4d..b85edba62 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -126,7 +126,6 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
break;
case BYTEARRAY_TYPECODE:
case 'B':
- case 'x': // value will be discarded
val = ((unsigned char*)p)[index];
break;
case 'h':
@@ -330,7 +329,11 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
}
}
- mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val);
+ if (val_type == 'x') {
+ memset(p, 0, 1);
+ } else {
+ mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val);
+ }
}
void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in) {
@@ -379,8 +382,6 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
case 'B':
((unsigned char*)p)[index] = val;
break;
- case 'x':
- ((unsigned char*)p)[index] = 0;
case 'h':
((short*)p)[index] = val;
break;