e576bb2002-10-11Martin Nilsson /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
7b62e22011-04-25Martin Stjernholm || $Id$
e576bb2002-10-11Martin Nilsson */
24ddc71998-03-28Henrik Grubbström (Grubba) 
5267b71995-08-09Fredrik Hübinette (Hubbe) #ifndef DYNAMIC_BUFFER_H #define DYNAMIC_BUFFER_H #define BUFFER_BEGIN_SIZE 4080
17ceb42002-10-21Marcus Comstedt struct dynbuf_string_s
5267b71995-08-09Fredrik Hübinette (Hubbe) { char *str; SIZE_T len; };
17ceb42002-10-21Marcus Comstedt typedef struct dynbuf_string_s dynbuf_string;
5267b71995-08-09Fredrik Hübinette (Hubbe)  struct dynamic_buffer_s {
17ceb42002-10-21Marcus Comstedt  dynbuf_string s;
5267b71995-08-09Fredrik Hübinette (Hubbe)  SIZE_T bufsize; }; typedef struct dynamic_buffer_s dynamic_buffer; /* Prototypes begin here */
f31ced2000-12-16Marcus Comstedt PMOD_EXPORT char *low_make_buf_space(size_t space, dynamic_buffer *buf);
7e877a2003-04-02Martin Stjernholm PMOD_EXPORT void low_my_putchar(int b,dynamic_buffer *buf);
f31ced2000-12-16Marcus Comstedt PMOD_EXPORT void low_my_binary_strcat(const char *b, size_t l, dynamic_buffer *buf); PMOD_EXPORT void debug_initialize_buf(dynamic_buffer *buf); PMOD_EXPORT void low_reinit_buf(dynamic_buffer *buf);
17ceb42002-10-21Marcus Comstedt PMOD_EXPORT void low_init_buf_with_string(dynbuf_string s, dynamic_buffer *buf);
f31ced2000-12-16Marcus Comstedt PMOD_EXPORT void toss_buffer(dynamic_buffer *buf); PMOD_EXPORT struct pike_string *debug_low_free_buf(dynamic_buffer *buf);
9fa0ee2003-11-09Martin Stjernholm  PMOD_EXPORT dynbuf_string complex_free_buf(dynamic_buffer *old_buf); PMOD_EXPORT char *simple_free_buf(dynamic_buffer *old_buf); PMOD_EXPORT struct pike_string *debug_free_buf(dynamic_buffer *old_buf);
f31ced2000-12-16Marcus Comstedt PMOD_EXPORT char *make_buf_space(INT32 space);
7e877a2003-04-02Martin Stjernholm PMOD_EXPORT void my_putchar(int b);
f31ced2000-12-16Marcus Comstedt PMOD_EXPORT void my_binary_strcat(const char *b, ptrdiff_t l); PMOD_EXPORT void my_strcat(const char *b);
9fa0ee2003-11-09Martin Stjernholm PMOD_EXPORT void init_buf(dynamic_buffer *old_buf); PMOD_EXPORT void init_buf_with_string(dynamic_buffer *old_buf, dynbuf_string s); PMOD_EXPORT void save_buffer (dynamic_buffer *save_buf); PMOD_EXPORT void restore_buffer (dynamic_buffer *save_buf); /* PMOD_EXPORT char *debug_return_buf(void); */
5267b71995-08-09Fredrik Hübinette (Hubbe) /* Prototypes end here */
61e9a01998-01-25Fredrik Hübinette (Hubbe) #ifdef DEBUG_MALLOC #define initialize_buf(X) \ do { dynamic_buffer *b_=(X); debug_initialize_buf(b_); \
20f7a02000-03-20Fredrik Hübinette (Hubbe)  debug_malloc_touch(b_->s.str); } while(0)
3c0c281998-01-26Fredrik Hübinette (Hubbe) #define low_free_buf(X) \
fe6bb62000-03-26Henrik Grubbström (Grubba)  ((struct pike_string *)debug_malloc_pass(debug_low_free_buf(X)))
3c0c281998-01-26Fredrik Hübinette (Hubbe) 
9fa0ee2003-11-09Martin Stjernholm #define free_buf(OLD_BUF) \ ((struct pike_string *)debug_malloc_pass(debug_free_buf(OLD_BUF)))
3c0c281998-01-26Fredrik Hübinette (Hubbe)  #define return_buf() \
fe6bb62000-03-26Henrik Grubbström (Grubba)  ((char *)debug_malloc_pass(debug_return_buf()))
3c0c281998-01-26Fredrik Hübinette (Hubbe) 
61e9a01998-01-25Fredrik Hübinette (Hubbe) #else #define initialize_buf debug_initialize_buf
3c0c281998-01-26Fredrik Hübinette (Hubbe) #define low_free_buf debug_low_free_buf #define free_buf debug_free_buf #define return_buf debug_return_buf
61e9a01998-01-25Fredrik Hübinette (Hubbe) #endif
5267b71995-08-09Fredrik Hübinette (Hubbe) #endif