diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/x1000-installer/src/xf_nandio.c | 2 | ||||
-rw-r--r-- | lib/x1000-installer/src/xf_package.c | 2 | ||||
-rw-r--r-- | lib/x1000-installer/test_lib/core_alloc.c | 7 | ||||
-rw-r--r-- | lib/x1000-installer/test_lib/core_alloc.h | 10 |
4 files changed, 19 insertions, 2 deletions
diff --git a/lib/x1000-installer/src/xf_nandio.c b/lib/x1000-installer/src/xf_nandio.c index ba79cbbcbf..29ff9d9120 100644 --- a/lib/x1000-installer/src/xf_nandio.c +++ b/lib/x1000-installer/src/xf_nandio.c | |||
@@ -51,7 +51,7 @@ int xf_nandio_init(struct xf_nandio* nio) | |||
51 | alloc_size += CACHEALIGN_SIZE - 1; | 51 | alloc_size += CACHEALIGN_SIZE - 1; |
52 | alloc_size += nio->block_size * 2; | 52 | alloc_size += nio->block_size * 2; |
53 | 53 | ||
54 | nio->alloc_handle = core_alloc("xf_nandio", alloc_size); | 54 | nio->alloc_handle = core_alloc_ex("xf_nandio", alloc_size, &buflib_ops_locked); |
55 | if(nio->alloc_handle < 0) { | 55 | if(nio->alloc_handle < 0) { |
56 | rc = XF_E_OUT_OF_MEMORY; | 56 | rc = XF_E_OUT_OF_MEMORY; |
57 | goto out_nclose; | 57 | goto out_nclose; |
diff --git a/lib/x1000-installer/src/xf_package.c b/lib/x1000-installer/src/xf_package.c index 78bddded68..04b32cdcb0 100644 --- a/lib/x1000-installer/src/xf_package.c +++ b/lib/x1000-installer/src/xf_package.c | |||
@@ -49,7 +49,7 @@ static int pkg_alloc(struct xf_package* pkg) | |||
49 | alloc_size += ALIGN_UP_P2(METADATA_SIZE, 3); | 49 | alloc_size += ALIGN_UP_P2(METADATA_SIZE, 3); |
50 | alloc_size += 7; /* for alignment */ | 50 | alloc_size += 7; /* for alignment */ |
51 | 51 | ||
52 | pkg->alloc_handle = core_alloc("xf_package", alloc_size); | 52 | pkg->alloc_handle = core_alloc_ex("xf_package", alloc_size, &buflib_ops_locked); |
53 | if(pkg->alloc_handle < 0) | 53 | if(pkg->alloc_handle < 0) |
54 | return XF_E_OUT_OF_MEMORY; | 54 | return XF_E_OUT_OF_MEMORY; |
55 | 55 | ||
diff --git a/lib/x1000-installer/test_lib/core_alloc.c b/lib/x1000-installer/test_lib/core_alloc.c index 5d4edb03f7..719670f8f2 100644 --- a/lib/x1000-installer/test_lib/core_alloc.c +++ b/lib/x1000-installer/test_lib/core_alloc.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #define N_POINTERS 100 | 25 | #define N_POINTERS 100 |
26 | 26 | ||
27 | static void* pointers[N_POINTERS]; | 27 | static void* pointers[N_POINTERS]; |
28 | struct buflib_callbacks buflib_ops_locked = {NULL, NULL, NULL}; | ||
28 | 29 | ||
29 | int core_alloc(const char* name, size_t size) | 30 | int core_alloc(const char* name, size_t size) |
30 | { | 31 | { |
@@ -46,6 +47,12 @@ int core_alloc(const char* name, size_t size) | |||
46 | return -1; | 47 | return -1; |
47 | } | 48 | } |
48 | 49 | ||
50 | int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks* cb) | ||
51 | { | ||
52 | (void)cb; | ||
53 | return core_alloc(name, size); | ||
54 | } | ||
55 | |||
49 | int core_free(int handle) | 56 | int core_free(int handle) |
50 | { | 57 | { |
51 | if(handle > 0) { | 58 | if(handle > 0) { |
diff --git a/lib/x1000-installer/test_lib/core_alloc.h b/lib/x1000-installer/test_lib/core_alloc.h index 6fb06649fb..2c77e3c274 100644 --- a/lib/x1000-installer/test_lib/core_alloc.h +++ b/lib/x1000-installer/test_lib/core_alloc.h | |||
@@ -25,8 +25,18 @@ | |||
25 | #define CORE_ALLOC_H | 25 | #define CORE_ALLOC_H |
26 | 26 | ||
27 | #include <stddef.h> | 27 | #include <stddef.h> |
28 | #include <stdbool.h> | ||
29 | |||
30 | struct buflib_callbacks { | ||
31 | int (*move_callback)(int handle, void* current, void* new); | ||
32 | int (*shrink_callback)(int handle, unsigned hints, void* start, size_t old_size); | ||
33 | void (*sync_callback)(int handle, bool sync_on); | ||
34 | }; | ||
35 | |||
36 | extern struct buflib_callbacks buflib_ops_locked; | ||
28 | 37 | ||
29 | int core_alloc(const char* name, size_t size); | 38 | int core_alloc(const char* name, size_t size); |
39 | int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks* cb); | ||
30 | int core_free(int handle); | 40 | int core_free(int handle); |
31 | void* core_get_data(int handle); | 41 | void* core_get_data(int handle); |
32 | 42 | ||