1/**
2 * @file op_growable_buffer.h
3 * a growable buffer interface
4 *
5 * @remark Copyright 2007 OProfile authors
6 * @remark Read the file COPYING
7 *
8 * @author Philippe Elie
9 */
10
11#ifndef OP_GROWABLE_BUFFER_H
12#define OP_GROWABLE_BUFFER_H
13
14#include <stddef.h>
15
16struct growable_buffer {
17	void * p;
18	size_t size;
19	size_t max_size;
20};
21
22/**
23 * init_buffer - initialize an empty buffer
24 * @param buffer the buffer to initialize
25 *
26 * init_buffer do not do any allocation, the first allocation will occur
27 * when add_data() with a non zero len param will be called.
28 */
29void init_buffer(struct growable_buffer * buffer);
30
31/**
32 * free_buffer - free the memory allocated for this buffer
33 * @param buffer the buffer to free
34 */
35void free_buffer(struct growable_buffer * buffer);
36
37/**
38 * add_data - add data to this buffer
39 * @param b the buffer where to add data
40 * @param data a pointer to the data to add
41 * @param len number of byte to add to the buffer
42 */
43void add_data(struct growable_buffer * b, void const * data, size_t len);
44
45#endif /* !OP_GROWABLE_BUFFER_H */
46