Skip to content

Commit

Permalink
MT#55283 upgrade minimum chunk allocation size
Browse files Browse the repository at this point in the history
Change-Id: I2fafa4055be06b22671abf789ea51cf6409c5e1b
  • Loading branch information
rfuchs committed Oct 11, 2024
1 parent 9f88270 commit bf0b178
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions daemon/bencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "helpers.h"

/* set to 0 for alloc debugging, e.g. through valgrind */
#define BENCODE_MIN_BUFFER_PIECE_LEN 512
#define BENCODE_MIN_BUFFER_PIECE_LEN 4096

#define BENCODE_HASH_BUCKETS 31 /* prime numbers work best */

Expand Down Expand Up @@ -78,14 +78,14 @@ static void __bencode_list_init(bencode_item_t *list) {
static struct __bencode_buffer_piece *__bencode_piece_new(size_t size) {
struct __bencode_buffer_piece *ret;

if (size < BENCODE_MIN_BUFFER_PIECE_LEN)
size = BENCODE_MIN_BUFFER_PIECE_LEN;
ret = BENCODE_MALLOC(sizeof(*ret) + size + BENCODE_ALLOC_ALIGN);
size_t alloc_size = size + sizeof(*ret) + BENCODE_ALLOC_ALIGN;
alloc_size = MAX(alloc_size, BENCODE_MIN_BUFFER_PIECE_LEN);
ret = BENCODE_MALLOC(alloc_size);
if (!ret)
return NULL;

ret->tail = ret->buf;
ret->left = size;
ret->left = alloc_size - sizeof(*ret) - BENCODE_ALLOC_ALIGN;
ret->next = NULL;

return ret;
Expand Down

0 comments on commit bf0b178

Please sign in to comment.