Fix align32_size().
It not only caused crashes with requests larger than 64K (can happen with RGBMatrix), but also generated a lot longer code than necessary.
This commit is contained in:
parent
a4b84cf0e1
commit
7ca36d45a4
|
@ -40,9 +40,9 @@ supervisor_allocation* usb_midi_allocation;
|
|||
|
||||
void usb_midi_init(void) {
|
||||
// TODO(tannewt): Make this dynamic.
|
||||
uint16_t tuple_size = align32_size(sizeof(mp_obj_tuple_t) + sizeof(mp_obj_t*) * 2);
|
||||
uint16_t portin_size = align32_size(sizeof(usb_midi_portin_obj_t));
|
||||
uint16_t portout_size = align32_size(sizeof(usb_midi_portout_obj_t));
|
||||
size_t tuple_size = align32_size(sizeof(mp_obj_tuple_t) + sizeof(mp_obj_t*) * 2);
|
||||
size_t portin_size = align32_size(sizeof(usb_midi_portin_obj_t));
|
||||
size_t portout_size = align32_size(sizeof(usb_midi_portout_obj_t));
|
||||
|
||||
// For each embedded MIDI Jack in the descriptor we create a Port
|
||||
usb_midi_allocation = allocate_memory(tuple_size + portin_size + portout_size, false, false);
|
||||
|
|
|
@ -64,11 +64,8 @@ supervisor_allocation* allocate_remaining_memory(void);
|
|||
// supervisor_move_memory().
|
||||
supervisor_allocation* allocate_memory(uint32_t length, bool high_address, bool movable);
|
||||
|
||||
static inline uint16_t align32_size(uint16_t size) {
|
||||
if (size % 4 != 0) {
|
||||
return (size & 0xfffc) + 0x4;
|
||||
}
|
||||
return size;
|
||||
static inline size_t align32_size(size_t size) {
|
||||
return (size + 3) & ~3;
|
||||
}
|
||||
|
||||
size_t get_allocation_length(supervisor_allocation* allocation);
|
||||
|
|
Loading…
Reference in New Issue