git » nmdb » commit 1fe50a3

Save vsize when replacing a cache entry.

author Alberto Bertogli
2007-01-07 05:46:21 UTC
committer Alberto Bertogli
2007-01-07 05:46:21 UTC
parent 6edf9833494d40dca7b39ac3b1f18c8909f178b0

Save vsize when replacing a cache entry.
When setting some value that already is in the cache, we replace the value
buffer but forgot to replace the value length. This patch fixes that by doing
the obvious thing: replacing the old length with the new one.

nmdb/cache.c +1 -0

diff --git a/nmdb/cache.c b/nmdb/cache.c
index a5a9806..27f426f 100644
--- a/nmdb/cache.c
+++ b/nmdb/cache.c
@@ -242,6 +242,7 @@ int cache_set(struct cache *cd, const unsigned char *key, size_t ksize,
 		}
 		free(e->val);
 		e->val = v;
+		e->vsize = vsize;
 		memcpy(e->val, val, vsize);
 
 		/* promote the entry to the top of the list if necessary */