summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-28 21:56:04 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-09-19 15:09:51 -0400
commit4d3bf1c446a7d1d2f85d368dfff70fcedfb5e045 (patch)
treecb972c9823030ed24d54075623785d092e8cbabc
parent840f6b79c73b7714843f38d179dbbd6bf45b822d (diff)
downloadrockbox-4d3bf1c446a7d1d2f85d368dfff70fcedfb5e045.tar.gz
rockbox-4d3bf1c446a7d1d2f85d368dfff70fcedfb5e045.zip
buflib: add comment in handle_alloc, remove a dead store
It isn't obvious why the "handle->val = -1" at the end of handle_alloc is needed so add an explanatory comment. But "handle->val = 1" prior to calling handle_free is simply a dead store. Change-Id: I9ab4e96e87e940cfd1a2ed56f089287821669c73
-rw-r--r--firmware/buflib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/firmware/buflib.c b/firmware/buflib.c
index 4b557eb59d..eccf8b057e 100644
--- a/firmware/buflib.c
+++ b/firmware/buflib.c
@@ -207,7 +207,11 @@ union buflib_data* handle_alloc(struct buflib_context *ctx)
207 * and the found handle, therefore we can update first_free_handle */ 207 * and the found handle, therefore we can update first_free_handle */
208 ctx->first_free_handle = handle - 1; 208 ctx->first_free_handle = handle - 1;
209 209
210 /* We need to set the table entry to a non-NULL value to ensure that
211 * compactions triggered by an allocation do not compact the handle
212 * table and delete this handle. */
210 handle->val = -1; 213 handle->val = -1;
214
211 return handle; 215 return handle;
212} 216}
213 217
@@ -613,7 +617,6 @@ buffer_alloc:
613 { 617 {
614 goto buffer_alloc; 618 goto buffer_alloc;
615 } else { 619 } else {
616 handle->val=1;
617 handle_free(ctx, handle); 620 handle_free(ctx, handle);
618 return -2; 621 return -2;
619 } 622 }