blob: 596d5d2567ead6845a979c7753426690602422a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include "buffer.h"
#include <stdlib.h>
#include <string.h>
void ab_append(struct append_buffer* ab, const char* string, int length)
{
char* new = realloc(ab->buffer, ab->length + length);
if (new == NULL)
return;
memcpy(&new[ab->length], string, length);
ab->buffer = new;
ab->length += length;
}
void ab_free(struct append_buffer* ab)
{
free(ab->buffer);
}
|