1 /*====================================================================* 2 - Copyright (C) 2001 Leptonica. All rights reserved. 3 - This software is distributed in the hope that it will be 4 - useful, but with NO WARRANTY OF ANY KIND. 5 - No author or distributor accepts responsibility to anyone for the 6 - consequences of using this software, or for whether it serves any 7 - particular purpose or works at all, unless he or she says so in 8 - writing. Everyone is granted permission to copy, modify and 9 - redistribute this source code, for commercial or non-commercial 10 - purposes, with the following restrictions: (1) the origin of this 11 - source code must not be misrepresented; (2) modified versions must 12 - be plainly marked as such; and (3) this notice may not be removed 13 - or altered from any source or modified source distribution. 14 *====================================================================*/ 15 16 #ifndef LEPTONICA_BBUFFER_H 17 #define LEPTONICA_BBUFFER_H 18 19 /* 20 * bbuffer.h 21 * 22 * Expandable byte buffer for reading data in from memory and 23 * writing data out to other memory. 24 * 25 * This implements a queue of bytes, so data read in is put 26 * on the "back" of the queue (i.e., the end of the byte array) 27 * and data written out is taken from the "front" of the queue 28 * (i.e., from an index marker "nwritten" that is initially set at 29 * the beginning of the array.) As usual with expandable 30 * arrays, we keep the size of the allocated array and the 31 * number of bytes that have been read into the array. 32 * 33 * For implementation details, see bbuffer.c. 34 */ 35 36 struct ByteBuffer 37 { 38 l_int32 nalloc; /* size of allocated byte array */ 39 l_int32 n; /* number of bytes read into to the array */ 40 l_int32 nwritten; /* number of bytes written from the array */ 41 l_uint8 *array; /* byte array */ 42 }; 43 typedef struct ByteBuffer BBUFFER; 44 45 46 #endif /* LEPTONICA_BBUFFER_H */ 47