buffer now stores the number of allocations for debug
This commit is contained in:
parent
ff45377ffe
commit
35c95790ed
2 changed files with 4 additions and 2 deletions
|
@ -1,11 +1,12 @@
|
|||
#include "buffer.h"
|
||||
|
||||
void buffer::write(char *data_in, int data_size)
|
||||
void buffer::write(char *data_in, size_t data_size)
|
||||
{
|
||||
if (data_size > allocated - size)
|
||||
{
|
||||
allocated += (size + data_size) + BUFFER_SIZE;
|
||||
data = (char *)realloc(data, allocated);
|
||||
allocations++;
|
||||
if (!data)
|
||||
{
|
||||
throw std::runtime_error("Allocation failed");
|
||||
|
|
|
@ -9,8 +9,9 @@ struct buffer
|
|||
char *data;
|
||||
size_t size;
|
||||
size_t allocated;
|
||||
int allocations;
|
||||
|
||||
void write(char *data_in, int data_size);
|
||||
void write(char *data_in, size_t data_size);
|
||||
void remove(int offset, int remove_size);
|
||||
|
||||
~buffer()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue