Re-use AOF buffer when it is small enough

This commit is contained in:
Pieter Noordhuis
2011-08-18 12:44:30 +02:00
committed by antirez
parent a57225c2cf
commit f990782f4d
3 changed files with 17 additions and 2 deletions

View File

@ -94,6 +94,13 @@ void sdsupdatelen(sds s) {
sh->len = reallen;
}
void sdsclear(sds s) {
struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));
sh->free += sh->len;
sh->len = 0;
sh->buf[0] = '\0';
}
static sds sdsMakeRoomFor(sds s, size_t addlen) {
struct sdshdr *sh, *newsh;
size_t free = sdsavail(s);