Revision | fc6705229cbca807f2bab9a8acf22b0ab249e55c (tree) |
---|---|
Time | 2022-01-28 23:38:23 |
Author | Juan Quintela <quintela@redh...> |
Commiter | Juan Quintela |
multifd: Use proper maximum compression values
It happens that there are functions to calculate the worst possible
compression size for a packet. Use them.
Suggested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
@@ -54,8 +54,8 @@ static int zlib_send_setup(MultiFDSendParams *p, Error **errp) | ||
54 | 54 | error_setg(errp, "multifd %u: deflate init failed", p->id); |
55 | 55 | return -1; |
56 | 56 | } |
57 | - /* To be safe, we reserve twice the size of the packet */ | |
58 | - z->zbuff_len = MULTIFD_PACKET_SIZE * 2; | |
57 | + /* This is the maxium size of the compressed buffer */ | |
58 | + z->zbuff_len = compressBound(MULTIFD_PACKET_SIZE); | |
59 | 59 | z->zbuff = g_try_malloc(z->zbuff_len); |
60 | 60 | if (!z->zbuff) { |
61 | 61 | deflateEnd(&z->zs); |
@@ -67,8 +67,8 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **errp) | ||
67 | 67 | p->id, ZSTD_getErrorName(res)); |
68 | 68 | return -1; |
69 | 69 | } |
70 | - /* To be safe, we reserve twice the size of the packet */ | |
71 | - z->zbuff_len = MULTIFD_PACKET_SIZE * 2; | |
70 | + /* This is the maxium size of the compressed buffer */ | |
71 | + z->zbuff_len = ZSTD_compressBound(MULTIFD_PACKET_SIZE); | |
72 | 72 | z->zbuff = g_try_malloc(z->zbuff_len); |
73 | 73 | if (!z->zbuff) { |
74 | 74 | ZSTD_freeCStream(z->zcs); |