summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorgreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-09-05 11:34:16 +0000
committergreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-09-05 11:34:16 +0000
commitea58a7cf0ed8f34fd75dbaa11d3c3d7dd2d9012c (patch)
tree7603592d8265b21ff9a20e9c2ecf066d059a3559 /src/common
parent2f7c1cad534e6e2ee079546437bee2bf172dafe5 (diff)
downloadhercules-ea58a7cf0ed8f34fd75dbaa11d3c3d7dd2d9012c.tar.gz
hercules-ea58a7cf0ed8f34fd75dbaa11d3c3d7dd2d9012c.tar.bz2
hercules-ea58a7cf0ed8f34fd75dbaa11d3c3d7dd2d9012c.tar.xz
hercules-ea58a7cf0ed8f34fd75dbaa11d3c3d7dd2d9012c.zip
Fixed ERS cache linked list algorithm.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16748 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r--src/common/ers.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/common/ers.c b/src/common/ers.c
index 514f09c34..b94b0888d 100644
--- a/src/common/ers.c
+++ b/src/common/ers.c
@@ -128,8 +128,10 @@ static ers_cache_t *ers_find_cache(unsigned int size)
}
else
{
- CacheList->Next = cache;
- cache->Prev = CacheList;
+ cache->Next = CacheList;
+ cache->Next->Prev = cache;
+ CacheList = cache;
+ CacheList->Prev = NULL;
}
return cache;
@@ -142,13 +144,12 @@ static void ers_free_cache(ers_cache_t *cache, bool remove)
for (i = 0; i < cache->Used; i++)
aFree(cache->Blocks[i]);
- if (cache->Prev)
- cache->Prev->Next = cache->Next;
-
if (cache->Next)
cache->Next->Prev = cache->Prev;
- if (CacheList == cache)
+ if (cache->Prev)
+ cache->Prev->Next = cache->Next;
+ else
CacheList = cache->Next;
aFree(cache->Blocks);