1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/*
Interface definitions for bget.c, the memory management package.
*/
typedef long bufsize;
struct qlinks {
struct bfhead *flink; /* Forward link */
struct bfhead *blink; /* Backward link */
};
/* Header in allocated and free buffers */
struct bhead {
bufsize prevfree; /* Relative link back to previous
free buffer in memory or 0 if
previous buffer is allocated. */
bufsize bsize; /* Buffer size: positive if free,
negative if allocated. */
};
#define BH(p) ((struct bhead *) (p))
/* Header in directly allocated buffers (by acqfcn) */
struct bdhead {
bufsize tsize; /* Total size, including overhead */
struct bhead bh; /* Common header */
};
#define BDH(p) ((struct bdhead *) (p))
/* Header in free buffers */
struct bfhead {
struct bhead bh; /* Common allocated/free header */
struct qlinks ql; /* Links on free list */
};
#define BFH(p) ((struct bfhead *) (p))
class BGet
{
public:
BGet();
struct bfhead freelist;/* = {
{0, 0},
{&freelist, &freelist}
};*/ /* List of free buffers */
void *(*acqfcn) (bufsize size);;
void bpool (void *buffer, bufsize len);
void *bget (bufsize size);
void *bgetz (bufsize size);
void *bgetr (void *buffer, bufsize newsize);
void brel (void *buf);
void bectl (void *(*acquire) (bufsize size), bufsize pool_incr);
};
|