buffer.c (204917) | buffer.c (224638) |
---|---|
1/* $OpenBSD: buffer.c,v 1.32 2010/02/09 03:56:28 djm Exp $ */ | 1/* $OpenBSD: buffer.c,v 1.32 2010/02/09 03:56:28 djm Exp $ */ |
2/* $FreeBSD$ */ |
|
2/* 3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 5 * All rights reserved 6 * Functions for manipulating fifo buffers (that can grow if needed). 7 * 8 * As far as I am concerned, the code I have written for this software 9 * can be used freely for any purpose. Any derived versions of this --- 10 unchanged lines hidden (view full) --- 20#include <string.h> 21#include <stdarg.h> 22 23#include "xmalloc.h" 24#include "buffer.h" 25#include "log.h" 26 27#define BUFFER_MAX_CHUNK 0x100000 | 3/* 4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 5 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 6 * All rights reserved 7 * Functions for manipulating fifo buffers (that can grow if needed). 8 * 9 * As far as I am concerned, the code I have written for this software 10 * can be used freely for any purpose. Any derived versions of this --- 10 unchanged lines hidden (view full) --- 21#include <string.h> 22#include <stdarg.h> 23 24#include "xmalloc.h" 25#include "buffer.h" 26#include "log.h" 27 28#define BUFFER_MAX_CHUNK 0x100000 |
28#define BUFFER_MAX_LEN 0xa00000 | 29#define BUFFER_MAX_LEN 0x4000000 /* 64MB */ |
29#define BUFFER_ALLOCSZ 0x008000 30 31/* Initializes the buffer structure. */ 32 33void 34buffer_init(Buffer *buffer) 35{ 36 const u_int len = 4096; --- 123 unchanged lines hidden (view full) --- 160/* Returns the number of bytes of data in the buffer. */ 161 162u_int 163buffer_len(const Buffer *buffer) 164{ 165 return buffer->end - buffer->offset; 166} 167 | 30#define BUFFER_ALLOCSZ 0x008000 31 32/* Initializes the buffer structure. */ 33 34void 35buffer_init(Buffer *buffer) 36{ 37 const u_int len = 4096; --- 123 unchanged lines hidden (view full) --- 161/* Returns the number of bytes of data in the buffer. */ 162 163u_int 164buffer_len(const Buffer *buffer) 165{ 166 return buffer->end - buffer->offset; 167} 168 |
169/* Returns the maximum number of bytes of data that may be in the buffer. */ 170u_int 171buffer_get_max_len(void) 172{ 173 return (BUFFER_MAX_LEN); 174} 175 |
|
168/* Gets data from the beginning of the buffer. */ 169 170int 171buffer_get_ret(Buffer *buffer, void *buf, u_int len) 172{ 173 if (len > buffer->end - buffer->offset) { 174 error("buffer_get_ret: trying to get more bytes %d than in buffer %d", 175 len, buffer->end - buffer->offset); --- 77 unchanged lines hidden --- | 176/* Gets data from the beginning of the buffer. */ 177 178int 179buffer_get_ret(Buffer *buffer, void *buf, u_int len) 180{ 181 if (len > buffer->end - buffer->offset) { 182 error("buffer_get_ret: trying to get more bytes %d than in buffer %d", 183 len, buffer->end - buffer->offset); --- 77 unchanged lines hidden --- |