From 9d2dc0249c5ef99586710d711e1381c4178aeb39 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Fri, 21 Nov 2014 14:52:10 -0500 Subject: Add ziplistMerge() This started out as #2158 by sunheehnus, but I kept rewriting it until I could understand things more easily and get a few more correctness guarantees out of the readability flow. The original commit created and returned a new ziplist with the contents of both input ziplists, but I prefer to grow one of the input ziplists and destroy the other one. So, instead of malloc+copy as in #2158, the merge now reallocs one of the existing ziplists and copies the other ziplist into the new space. Also added merge test cases to ziplistTest() --- src/ziplist.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ziplist.h') diff --git a/src/ziplist.h b/src/ziplist.h index ef0e27140..e92b5e783 100644 --- a/src/ziplist.h +++ b/src/ziplist.h @@ -32,6 +32,7 @@ #define ZIPLIST_TAIL 1 unsigned char *ziplistNew(void); +unsigned char *ziplistMerge(unsigned char **first, unsigned char **second); unsigned char *ziplistPush(unsigned char *zl, unsigned char *s, unsigned int slen, int where); unsigned char *ziplistIndex(unsigned char *zl, int index); unsigned char *ziplistNext(unsigned char *zl, unsigned char *p); -- cgit v1.2.1