Commit 1fe93863 authored by Brad Hards's avatar Brad Hards Committed by Rusty Russell

alloc: avoid dead store to hdrlen

We only ever write to this variable, so can just be removed.
parent edede43e
...@@ -137,12 +137,12 @@ void tiny_alloc_init(void *pool, unsigned long poolsize) ...@@ -137,12 +137,12 @@ void tiny_alloc_init(void *pool, unsigned long poolsize)
/* Walk through and try to coalesce */ /* Walk through and try to coalesce */
static bool try_coalesce(unsigned char *pool, unsigned long poolsize) static bool try_coalesce(unsigned char *pool, unsigned long poolsize)
{ {
unsigned long len, hdrlen, prev_off = 0, prev_len = 0, off; unsigned long len, prev_off = 0, prev_len = 0, off;
bool free, prev_free = false, coalesced = false; bool free, prev_free = false, coalesced = false;
off = free_array_size(poolsize); off = free_array_size(poolsize);
do { do {
hdrlen = decode(&len, &free, pool + off); decode(&len, &free, pool + off);
if (free && prev_free) { if (free && prev_free) {
prev_len += len; prev_len += len;
encode(prev_len, true, pool + prev_off); encode(prev_len, true, pool + prev_off);
...@@ -198,7 +198,7 @@ void *tiny_alloc_get(void *pool, unsigned long poolsize, ...@@ -198,7 +198,7 @@ void *tiny_alloc_get(void *pool, unsigned long poolsize,
unsigned long size, unsigned long align) unsigned long size, unsigned long align)
{ {
unsigned long arrsize = free_array_size(poolsize); unsigned long arrsize = free_array_size(poolsize);
unsigned long len, off, actual, hdr, hdrlen, free_bucket; unsigned long len, off, actual, hdr, free_bucket;
long fa_off; long fa_off;
unsigned char *arr = pool; unsigned char *arr = pool;
bool free, coalesced = false; bool free, coalesced = false;
...@@ -224,7 +224,7 @@ void *tiny_alloc_get(void *pool, unsigned long poolsize, ...@@ -224,7 +224,7 @@ void *tiny_alloc_get(void *pool, unsigned long poolsize,
if (!off) if (!off)
continue; continue;
hdrlen = decode(&len, &free, arr + off); decode(&len, &free, arr + off);
if (long_enough(off, len, size, align)) { if (long_enough(off, len, size, align)) {
/* Remove it. */ /* Remove it. */
memset(&arr[fa_off], 0, 3); memset(&arr[fa_off], 0, 3);
...@@ -236,7 +236,7 @@ void *tiny_alloc_get(void *pool, unsigned long poolsize, ...@@ -236,7 +236,7 @@ void *tiny_alloc_get(void *pool, unsigned long poolsize,
again: again:
off = arrsize; off = arrsize;
hdrlen = decode(&len, &free, arr + off); decode(&len, &free, arr + off);
while (!free || !long_enough(off, len, size, align)) { while (!free || !long_enough(off, len, size, align)) {
/* Refill free array as we go. */ /* Refill free array as we go. */
if (free && coalesced) if (free && coalesced)
...@@ -251,7 +251,7 @@ again: ...@@ -251,7 +251,7 @@ again:
} }
return NULL; return NULL;
} }
hdrlen = decode(&len, &free, arr + off); decode(&len, &free, arr + off);
} }
found: found:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment