Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

buflib: add handle_to_block_end

Change-Id: I598cf32bc8cd08ab4bca3827645e0a38b284468f

+15 -1
+15 -1
firmware/buflib.c
··· 317 317 ctx->compact = false; 318 318 } 319 319 320 + static inline 321 + union buflib_data* handle_to_block_end(struct buflib_context *ctx, int handle) 322 + { 323 + void *ptr = buflib_get_data(ctx, handle); 324 + 325 + /* this is a valid case for shrinking if handle 326 + * was freed by the shrink callback */ 327 + if (!ptr) 328 + return NULL; 329 + 330 + union buflib_data *data = ALIGN_DOWN(ptr, sizeof(*data)); 331 + return data; 332 + } 333 + 320 334 /* Get the start block of an allocation */ 321 335 static inline 322 336 union buflib_data* handle_to_block(struct buflib_context* ctx, int handle) ··· 1038 1052 1039 1053 const char* buflib_get_name(struct buflib_context *ctx, int handle) 1040 1054 { 1041 - union buflib_data *data = ALIGN_DOWN(buflib_get_data(ctx, handle), sizeof (*data)); 1055 + union buflib_data *data = handle_to_block_end(ctx, handle); 1042 1056 size_t len = data[-bidx_BSIZE].val; 1043 1057 if (len <= BUFLIB_NUM_FIELDS) 1044 1058 return NULL;