mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Remove useless memmove() from freeMemoryIfNeeded().
We start from the end of the pool to the initial item, zero-ing every entry we use or every ghost entry, there is nothing to memmove since to the right everything should be already set to NULL.
This commit is contained in:
parent
b19b2dff46
commit
382991f82e
@ -264,13 +264,8 @@ int freeMemoryIfNeeded(void) {
|
||||
|
||||
/* Remove the entry from the pool. */
|
||||
sdsfree(pool[k].key);
|
||||
/* Shift all elements on its right to left. */
|
||||
memmove(pool+k,pool+k+1,
|
||||
sizeof(pool[0])*(MAXMEMORY_EVICTION_POOL_SIZE-k-1));
|
||||
/* Clear the element on the right which is empty
|
||||
* since we shifted one position to the left. */
|
||||
pool[MAXMEMORY_EVICTION_POOL_SIZE-1].key = NULL;
|
||||
pool[MAXMEMORY_EVICTION_POOL_SIZE-1].idle = 0;
|
||||
pool[k].key = NULL;
|
||||
pool[k].idle = 0;
|
||||
|
||||
/* If the key exists, is our pick. Otherwise it is
|
||||
* a ghost and we need to try the next element. */
|
||||
|
Loading…
Reference in New Issue
Block a user