00001 /** 00002 * @file op_growable_buffer.h 00003 * a growable buffer interface 00004 * 00005 * @remark Copyright 2007 OProfile authors 00006 * @remark Read the file COPYING 00007 * 00008 * @author Philippe Elie 00009 */ 00010 00011 #ifndef OP_GROWABLE_BUFFER_H 00012 #define OP_GROWABLE_BUFFER_H 00013 00014 #include <stddef.h> 00015 00016 struct growable_buffer { 00017 void * p; 00018 size_t size; 00019 size_t max_size; 00020 }; 00021 00022 /** 00023 * init_buffer - initialize an empty buffer 00024 * @param buffer the buffer to initialize 00025 * 00026 * init_buffer do not do any allocation, the first allocation will occur 00027 * when add_data() with a non zero len param will be called. 00028 */ 00029 void init_buffer(struct growable_buffer * buffer); 00030 00031 /** 00032 * free_buffer - free the memory allocated for this buffer 00033 * @param buffer the buffer to free 00034 */ 00035 void free_buffer(struct growable_buffer * buffer); 00036 00037 /** 00038 * add_data - add data to this buffer 00039 * @param b the buffer where to add data 00040 * @param data a pointer to the data to add 00041 * @param len number of byte to add to the buffer 00042 */ 00043 void add_data(struct growable_buffer * b, void const * data, size_t len); 00044 00045 #endif /* !OP_GROWABLE_BUFFER_H */
1.6.1