Rewrite blockdata_retrieve() and expand_buf() to use realloc().

This commit is contained in:
Simon Kelley committed 2026-02-01 21:56:30 +00:00
1 parent 19f3e06e7a
commit fbfcf87f8b
2 files changed
+7 -15

No files matched your search

+6 -8
View File
@@ -193,22 +193,20 @@ void *blockdata_retrieve(struct blockdata *block, size_t len, void *data)
{
size_t blen;
struct blockdata *b;
uint8_t *new, *d;
uint8_t *d;
static unsigned int buff_len = 0;
static unsigned char *buff = NULL;
if (!data)
{
static unsigned int buff_len = 0;
static unsigned char *buff = NULL;
uint8_t *new;
if (len > buff_len)
{
blen = len + 1024;
if (!(new = whine_malloc(blen)))
if (!(new = whine_realloc(buff, blen)))
return NULL;
if (buff)
free(buff);
buff = new;
buff_len = blen;
}