summaryrefslogtreecommitdiff
path: root/firmware/buflib.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/buflib.c')
-rw-r--r--firmware/buflib.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/firmware/buflib.c b/firmware/buflib.c
index eccf8b057e..5b837aa439 100644
--- a/firmware/buflib.c
+++ b/firmware/buflib.c
@@ -247,18 +247,20 @@ union buflib_data* handle_to_block(struct buflib_context* ctx, int handle)
247/* Shrink the handle table, returning true if its size was reduced, false if 247/* Shrink the handle table, returning true if its size was reduced, false if
248 * not 248 * not
249 */ 249 */
250static inline 250static inline bool handle_table_shrink(struct buflib_context *ctx)
251bool
252handle_table_shrink(struct buflib_context *ctx)
253{ 251{
254 bool rv;
255 union buflib_data *handle; 252 union buflib_data *handle;
256 for (handle = ctx->last_handle; !(handle->alloc); handle++); 253 union buflib_data *old_last = ctx->last_handle;
254
255 for (handle = ctx->last_handle; handle != ctx->handle_table; ++handle)
256 if (handle->alloc)
257 break;
258
257 if (handle > ctx->first_free_handle) 259 if (handle > ctx->first_free_handle)
258 ctx->first_free_handle = handle - 1; 260 ctx->first_free_handle = handle - 1;
259 rv = handle != ctx->last_handle; 261
260 ctx->last_handle = handle; 262 ctx->last_handle = handle;
261 return rv; 263 return handle != old_last;
262} 264}
263 265
264 266