diff options
| author | DavePutz <dwputz@gmail.com> | 2020-09-14 16:50:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-14 16:50:40 -0500 |
| commit | 2a2a8d64571bf93e2a166626841555fe1753a565 (patch) | |
| tree | a4b7ba795a6e17d4d0b32abd942af380b1c36e57 /py/binary.c | |
| parent | 4a3be4df91837a1c71fcbd62e041f7c45cd4dd4b (diff) | |
| parent | 3d8bac50e41acc286cefbde9e052c5ccb335101e (diff) | |
Merge pull request #28 from adafruit/main
Merge from adafruit/main
Diffstat (limited to 'py/binary.c')
| -rw-r--r-- | py/binary.c | 9 |
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; |
