[BACK]Return to buffer.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/Attic/buffer.c between version 1.16 and 1.16.4.2

version 1.16, 2002/06/26 08:54:18 version 1.16.4.2, 2003/09/16 21:30:49
Line 23 
Line 23 
 void  void
 buffer_init(Buffer *buffer)  buffer_init(Buffer *buffer)
 {  {
         buffer->alloc = 4096;          const u_int len = 4096;
         buffer->buf = xmalloc(buffer->alloc);  
           buffer->alloc = 0;
           buffer->buf = xmalloc(len);
           buffer->alloc = len;
         buffer->offset = 0;          buffer->offset = 0;
         buffer->end = 0;          buffer->end = 0;
 }  }
Line 34 
Line 37 
 void  void
 buffer_free(Buffer *buffer)  buffer_free(Buffer *buffer)
 {  {
         memset(buffer->buf, 0, buffer->alloc);          if (buffer->alloc > 0) {
         xfree(buffer->buf);                  memset(buffer->buf, 0, buffer->alloc);
                   xfree(buffer->buf);
           }
 }  }
   
 /*  /*
Line 69 
Line 74 
 void *  void *
 buffer_append_space(Buffer *buffer, u_int len)  buffer_append_space(Buffer *buffer, u_int len)
 {  {
           u_int newlen;
         void *p;          void *p;
   
         if (len > 0x100000)          if (len > 0x100000)
Line 98 
Line 104 
                 goto restart;                  goto restart;
         }          }
         /* Increase the size of the buffer and retry. */          /* Increase the size of the buffer and retry. */
         buffer->alloc += len + 32768;  
         if (buffer->alloc > 0xa00000)          newlen = buffer->alloc + len + 32768;
           if (newlen > 0xa00000)
                 fatal("buffer_append_space: alloc %u not supported",                  fatal("buffer_append_space: alloc %u not supported",
                     buffer->alloc);                      newlen);
         buffer->buf = xrealloc(buffer->buf, buffer->alloc);          buffer->buf = xrealloc(buffer->buf, newlen);
           buffer->alloc = newlen;
         goto restart;          goto restart;
         /* NOTREACHED */          /* NOTREACHED */
 }  }

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.16.4.2