pike.git / src / dynamic_buffer.c

version» Context lines:

pike.git/src/dynamic_buffer.c:4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h"   #include "dynamic_buffer.h"   #include "stralloc.h"   #include "error.h"   #include "pike_memory.h"      static dynamic_buffer buff;    - char *low_make_buf_space(INT32 space,dynamic_buffer *buf) + char *low_make_buf_space(INT32 space, dynamic_buffer *buf)   {    char *ret;   #ifdef DEBUG    if(!buf->s.str) fatal("ARRRRGH! Deadly Trap!\n");   #endif    -  if(buf->s.len+space>=buf->bufsize) +  if(buf->s.len+space >= buf->bufsize)    {    if(!buf->bufsize) buf->bufsize=1;       do{    buf->bufsize*=2; -  }while(buf->s.len+space>=buf->bufsize); +  }while(buf->s.len+space >= buf->bufsize);    -  buf->s.str=(char *)realloc(buf->s.str,buf->bufsize); +  buf->s.str=(char *)realloc(buf->s.str, buf->bufsize);    if(!buf->s.str)    error("Out of memory.\n");    } -  ret=buf->s.str + buf->s.len; -  buf->s.len+=space; +  ret = buf->s.str + buf->s.len; +  buf->s.len += space;    return ret;   }      void low_my_putchar(char b,dynamic_buffer *buf)   {   #ifdef DEBUG    if(!buf->s.str)    fatal("Error in internal buffering.\n");   #endif    low_make_buf_space(1,buf)[0]=b;
pike.git/src/dynamic_buffer.c:65:   {    if(!buf->s.str)    {    initialize_buf(buf);    }else{    *(buf->s.str)=0;    buf->s.len=0;    }   }    - void low_init_buf_with_string(string s,dynamic_buffer *buf) + 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) initialize_buf(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);   #ifdef DEBUG    if(!buf->s.str)