buffer: allow a buffer to shrink gracefully

the idea behind this patch is to allow the buffer to shrink, but
make this a seldom operation. The buffers average size is measured
exponentionally smoothed with am alpha of 1/128.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1446203414-4013-20-git-send-email-kraxel@redhat.com
This commit is contained in:
Peter Lieven 2015-10-30 12:10:14 +01:00 committed by Gerd Hoffmann
parent 4ec5ba151f
commit f14c3d85b0
2 changed files with 34 additions and 8 deletions

View file

@ -37,6 +37,7 @@ struct Buffer {
char *name;
size_t capacity;
size_t offset;
uint64_t avg_size;
uint8_t *buffer;
};