pike.git / src / dynamic_buffer.c

version» Context lines:

pike.git/src/dynamic_buffer.c:47:   void low_my_binary_strcat(const char *b,INT32 l,dynamic_buffer *buf)   {   #ifdef DEBUG    if(!buf->s.str)    fatal("Error in internal buffering.\n");   #endif       MEMCPY(low_make_buf_space(l,buf),b,l);   }    - void low_init_buf(dynamic_buffer *buf) + void initialize_buf(dynamic_buffer *buf)   { -  if(!buf->s.str) +     buf->s.str=(char *)xalloc((buf->bufsize=BUFFER_BEGIN_SIZE)); -  +  *(buf->s.str)=0; +  buf->s.len=0; + } +  + void low_reinit_buf(dynamic_buffer *buf) + {    if(!buf->s.str) -  error("Out of memory.\n"); +  { +  initialize_buf(buf); +  }else{    *(buf->s.str)=0;    buf->s.len=0;    } -  + }      void low_init_buf_with_string(string s,dynamic_buffer *buf)   {    if(buf->s.str) { free(buf->s.str); buf->s.str=NULL; }    buf->s=s;    if(!buf->s.str) init_buf();    /* if the string is an old buffer, this realloc will set the old    the bufsize back */    for(buf->bufsize=BUFFER_BEGIN_SIZE;buf->bufsize<buf->s.len;buf->bufsize*=2);    buf->s.str=realloc(buf->s.str,buf->bufsize);
pike.git/src/dynamic_buffer.c:107:    buf->s.str=0;    buf->s.len=0;    return q;   }      struct pike_string *free_buf(void) { return low_free_buf(&buff); }   char *make_buf_space(INT32 space) { return low_make_buf_space(space,&buff); }   void my_putchar(char b) { low_my_putchar(b,&buff); }   void my_binary_strcat(const char *b,INT32 l) { low_my_binary_strcat(b,l,&buff); }   void my_strcat(const char *b) { my_binary_strcat(b,strlen(b)); } - void init_buf(void) { low_init_buf(&buff); } + void init_buf(void) { low_reinit_buf(&buff); }   void init_buf_with_string(string s) { low_init_buf_with_string(s,&buff); }   char *return_buf(void)   {    my_putchar(0);    return buff.s.str;   }   /* int my_get_buf_size() { return buff->s.len; } */