1
0
Fork 0
forked from len0rd/rockbox

buflib: add a common dummy callbacks struct & use it

There are various allocations that can't be moved or shrunk.
Provide a global callback struct for this use case instead of
making each caller declare its own dummy struct.

Also fixed ROLO and x1000 installer code which incorrectly
used movable allocations.

Change-Id: I00088396b9826e02e69a4a33477fe1a7816374f1
This commit is contained in:
Aidan MacDonald 2022-01-18 18:57:06 +00:00
parent 95dfc489b5
commit e8faf2f2ad
14 changed files with 43 additions and 30 deletions

View file

@ -449,12 +449,11 @@ void usb_storage_init_connection(void)
#endif
#else
unsigned char * buffer;
/* dummy ops with no callbacks, needed because by
* default buflib buffers can be moved around which must be avoided */
static struct buflib_callbacks dummy_ops;
// Add 31 to handle worst-case misalignment
usb_handle = core_alloc_ex("usb storage", ALLOCATE_BUFFER_SIZE + MAX_CBW_SIZE + 31, &dummy_ops);
usb_handle = core_alloc_ex("usb storage",
ALLOCATE_BUFFER_SIZE + MAX_CBW_SIZE + 31,
&buflib_ops_locked);
if (usb_handle < 0)
panicf("%s(): OOM", __func__);