summaryrefslogtreecommitdiff
path: root/firmware/include
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-10-15 23:55:39 +0100
committerAidan MacDonald <amachronic@protonmail.com>2023-01-13 10:32:54 +0000
commit1e9ad3ca0d9bf3e917eb2beb460421155144760a (patch)
tree752590b42f338f03223e024fc5b642ac9a8a5598 /firmware/include
parent3301c5aa6db76832dbb9af8f72d29b348190fd91 (diff)
downloadrockbox-1e9ad3ca0d9bf3e917eb2beb460421155144760a.tar.gz
rockbox-1e9ad3ca0d9bf3e917eb2beb460421155144760a.zip
Remove buflib allocation names, part two
Remove allocation names from the buflib API and fix up all callers. Change-Id: I3df922e258d5f0d711d70e72b56b4ed634fb0f5a
Diffstat (limited to 'firmware/include')
-rw-r--r--firmware/include/buflib.h23
-rw-r--r--firmware/include/core_alloc.h7
2 files changed, 7 insertions, 23 deletions
diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h
index d2231ab79d..e54ec72a99 100644
--- a/firmware/include/buflib.h
+++ b/firmware/include/buflib.h
@@ -62,8 +62,7 @@ struct buflib_context
62 * to the actually requested number of bytes. 62 * to the actually requested number of bytes.
63 * 63 *
64 * The total number of bytes consumed by an allocation is 64 * The total number of bytes consumed by an allocation is
65 * BUFLIB_ALLOC_OVERHEAD + requested bytes + strlen(<name passed to 65 * BUFLIB_ALLOC_OVERHEAD + requested bytes + pad to pointer size
66 * buflib_alloc_ex()) + pad to pointer size
67 */ 66 */
68#define BUFLIB_ALLOC_OVERHEAD (5*sizeof(union buflib_data)) 67#define BUFLIB_ALLOC_OVERHEAD (5*sizeof(union buflib_data))
69 68
@@ -215,7 +214,6 @@ int buflib_alloc(struct buflib_context *context, size_t size);
215 * Allocates memory from the buflib's memory pool with additional callbacks 214 * Allocates memory from the buflib's memory pool with additional callbacks
216 * and flags 215 * and flags
217 * 216 *
218 * name: A string identifier giving this allocation a name
219 * size: How many bytes to allocate 217 * size: How many bytes to allocate
220 * ops: a struct with pointers to callback functions (see above). 218 * ops: a struct with pointers to callback functions (see above).
221 * if "ops" is NULL: Buffer is movable. 219 * if "ops" is NULL: Buffer is movable.
@@ -223,7 +221,7 @@ int buflib_alloc(struct buflib_context *context, size_t size);
223 * Returns: A positive integer handle identifying this allocation, or 221 * Returns: A positive integer handle identifying this allocation, or
224 * a negative value on error (0 is also not a valid handle) 222 * a negative value on error (0 is also not a valid handle)
225 */ 223 */
226int buflib_alloc_ex(struct buflib_context *ctx, size_t size, const char *name, 224int buflib_alloc_ex(struct buflib_context *ctx, size_t size,
227 struct buflib_callbacks *ops); 225 struct buflib_callbacks *ops);
228 226
229 227
@@ -241,15 +239,14 @@ int buflib_alloc_ex(struct buflib_context *ctx, size_t size, const char *name,
241 * and even shrinks other allocations. However, do not depend on this behavior, 239 * and even shrinks other allocations. However, do not depend on this behavior,
242 * it may change. 240 * it may change.
243 * 241 *
244 * name: A string identifier giving this allocation a name
245 * size: The actual size will be returned into size 242 * size: The actual size will be returned into size
246 * ops: a struct with pointers to callback functions 243 * ops: a struct with pointers to callback functions
247 * 244 *
248 * Returns: A positive integer handle identifying this allocation, or 245 * Returns: A positive integer handle identifying this allocation, or
249 * a negative value on error (0 is also not a valid handle) 246 * a negative value on error (0 is also not a valid handle)
250 */ 247 */
251int buflib_alloc_maximum(struct buflib_context* ctx, const char* name, 248int buflib_alloc_maximum(struct buflib_context* ctx,
252 size_t *size, struct buflib_callbacks *ops); 249 size_t *size, struct buflib_callbacks *ops);
253 250
254/** 251/**
255 * Queries the data pointer for the given handle. It's actually a cheap 252 * Queries the data pointer for the given handle. It's actually a cheap
@@ -349,18 +346,6 @@ void buflib_buffer_in(struct buflib_context *ctx, int size);
349/* debugging */ 346/* debugging */
350 347
351/** 348/**
352 * Returns the name, as given to buflib_alloc() and buflib_allloc_ex(), of the
353 * allocation associated with the given handle. As naming allocations
354 * is optional, there might be no name associated.
355 *
356 * handle: The handle indicating the allocation
357 *
358 * Returns: A pointer to the string identifier of the allocation, or NULL
359 * if none was specified with buflib_alloc_ex().
360 */
361const char* buflib_get_name(struct buflib_context *ctx, int handle);
362
363/**
364 * Gets the number of blocks in the entire buffer, allocated or unallocated 349 * Gets the number of blocks in the entire buffer, allocated or unallocated
365 * 350 *
366 * Only available if BUFLIB_DEBUG_BLOCK_SIGNLE is defined 351 * Only available if BUFLIB_DEBUG_BLOCK_SIGNLE is defined
diff --git a/firmware/include/core_alloc.h b/firmware/include/core_alloc.h
index 13d8165be2..8011c227b1 100644
--- a/firmware/include/core_alloc.h
+++ b/firmware/include/core_alloc.h
@@ -11,9 +11,9 @@
11 * they have a predefined context 11 * they have a predefined context
12 */ 12 */
13void core_allocator_init(void) INIT_ATTR; 13void core_allocator_init(void) INIT_ATTR;
14int core_alloc(const char* name, size_t size); 14int core_alloc(size_t size);
15int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks *ops); 15int core_alloc_ex(size_t size, struct buflib_callbacks *ops);
16int core_alloc_maximum(const char* name, size_t *size, struct buflib_callbacks *ops); 16int core_alloc_maximum(size_t *size, struct buflib_callbacks *ops);
17bool core_shrink(int handle, void* new_start, size_t new_size); 17bool core_shrink(int handle, void* new_start, size_t new_size);
18void core_pin(int handle); 18void core_pin(int handle);
19void core_unpin(int handle); 19void core_unpin(int handle);
@@ -21,7 +21,6 @@ unsigned core_pin_count(int handle);
21int core_free(int handle); 21int core_free(int handle);
22size_t core_available(void); 22size_t core_available(void);
23size_t core_allocatable(void); 23size_t core_allocatable(void);
24const char* core_get_name(int handle);
25#ifdef DEBUG 24#ifdef DEBUG
26void core_check_valid(void); 25void core_check_valid(void);
27#endif 26#endif