return 1;
}
+/* Return a pointer to the text within a growing_buffer, */
+/* while destroying the growing_buffer itself. */
+
+char* buffer_release( growing_buffer* gb) {
+ char* s = gb->buf;
+ s[gb->n_used] = '\0';
+ free( gb );
+ return s;
+}
+
+/* Destroy a growing_buffer and the text it contains */
+
int buffer_free( growing_buffer* gb ) {
if( gb == NULL )
return 0;
#include "md5.h"
#define OSRF_MALLOC(ptr, size) \
- ptr = (void*) malloc( size ); \
- if( ptr == NULL ) { \
- perror("OSRF_MALLOC(): Out of Memory" );\
- exit(99); \
- } \
- memset( ptr, 0, size );
+ do {\
+ ptr = (void*) malloc( size ); \
+ if( ptr == NULL ) { \
+ perror("OSRF_MALLOC(): Out of Memory" );\
+ exit(99); \
+ } \
+ memset( ptr, 0, size );\
+ } while(0)
#define OSRF_BUFFER_ADD(gb, data) \
int buffer_fadd(growing_buffer* gb, const char* format, ... );
int buffer_reset( growing_buffer* gb);
char* buffer_data( growing_buffer* gb);
+char* buffer_release( growing_buffer* gb );
int buffer_free( growing_buffer* gb );
int buffer_add_char(growing_buffer* gb, char c);