forked from yaosj2k/dnsforwarder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stablebuffer.h
executable file
·50 lines (35 loc) · 1.24 KB
/
stablebuffer.h
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
#ifndef STABLEBUFFER_C_INCLUDED
#define STABLEBUFFER_C_INCLUDED
#include "array.h"
typedef struct _StableBuffer_MetaInfo{
char *Start;
int32_t Amount; /* In bytes */
int32_t Used; /* In bytes */
} StableBuffer_MetaInfo;
typedef struct _StableBuffer StableBuffer;
struct _StableBuffer{
Array MetaInfo;
int32_t BlockSize;
void *(*Add)(StableBuffer *s, const void *Data, int Length);
void (*Clear)(StableBuffer *s);
void (*Free)(StableBuffer *s);
};
int StableBuffer_Init(StableBuffer *s);
/**
Iterator
*/
typedef struct _StableBufferIterator StableBufferIterator;
struct _StableBufferIterator{
StableBuffer *Buffer;
int32_t Current;
void *(*NextBlock)(StableBufferIterator *i);
void (*Reset)(StableBufferIterator *i);
void *(*ToLast)(StableBufferIterator *i);
BOOL (*IsInCurrentBlock)(StableBufferIterator *i, const void *Position);
int32_t (*CurrentBlockSize)(StableBufferIterator *i);
int32_t (*CurrentBlockUsed)(StableBufferIterator *i);
void (*RemoveLastNBytesOfCurrentBlock)(StableBufferIterator *i, int n);
void (*Free)(StableBufferIterator *i);
};
int StableBufferIterator_Init(StableBufferIterator *i, StableBuffer *s);
#endif // STABLEBUFFER_C_INCLUDED