mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 12:45:26 -05:00
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:
parent
95dfc489b5
commit
e8faf2f2ad
14 changed files with 43 additions and 30 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#define N_POINTERS 100
|
||||
|
||||
static void* pointers[N_POINTERS];
|
||||
struct buflib_callbacks buflib_ops_locked = {NULL, NULL, NULL};
|
||||
|
||||
int core_alloc(const char* name, size_t size)
|
||||
{
|
||||
|
|
@ -46,6 +47,12 @@ int core_alloc(const char* name, size_t size)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks* cb)
|
||||
{
|
||||
(void)cb;
|
||||
return core_alloc(name, size);
|
||||
}
|
||||
|
||||
int core_free(int handle)
|
||||
{
|
||||
if(handle > 0) {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,18 @@
|
|||
#define CORE_ALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct buflib_callbacks {
|
||||
int (*move_callback)(int handle, void* current, void* new);
|
||||
int (*shrink_callback)(int handle, unsigned hints, void* start, size_t old_size);
|
||||
void (*sync_callback)(int handle, bool sync_on);
|
||||
};
|
||||
|
||||
extern struct buflib_callbacks buflib_ops_locked;
|
||||
|
||||
int core_alloc(const char* name, size_t size);
|
||||
int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks* cb);
|
||||
int core_free(int handle);
|
||||
void* core_get_data(int handle);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue