Skip to content

Commit 3878455

Browse files
committedFeb 22, 2015
- Fix buffer reset.
1 parent fdcec53 commit 3878455

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎pseudo_node.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,10 @@ static uint64_t rand64(void)
584584
static struct buf *alloc_buf(jmp_buf *env)
585585
{
586586
struct buf *buf = (struct buf *)mem_alloc(sizeof(struct buf));
587-
size_t len = BUFFER_SIZE;
588-
char *data = (char *)mem_alloc(len);
587+
char *data = (char *)mem_alloc(BUFFER_SIZE);
589588
buf->env = env;
590589
buf->data = data;
591-
buf->len = len;
590+
buf->len = BUFFER_SIZE;
592591
buf->ptr = 0;
593592
buf->ref_count = 1;
594593
return buf;
@@ -600,9 +599,9 @@ static void reset_buf(struct buf *buf)
600599
if (buf->len > BUFFER_SIZE)
601600
{
602601
mem_free(buf->data);
603-
buf->len = BUFFER_SIZE;
604-
buf->data = (char *)mem_alloc(buf->len);
602+
buf->data = (char *)mem_alloc(BUFFER_SIZE);
605603
}
604+
buf->len = BUFFER_SIZE;
606605
buf->ptr = 0;
607606
}
608607

0 commit comments

Comments
 (0)
Please sign in to comment.