]>
Commit | Line | Data |
---|---|---|
528b2c61 | 1 | /* |
77b1029d | 2 | * Copyright (C) 1996-2020 The Squid Software Foundation and contributors |
528b2c61 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
528b2c61 | 7 | */ |
8 | ||
9 | #ifndef SQUID_STMEM_H | |
10 | #define SQUID_STMEM_H | |
11 | ||
21dfc374 | 12 | #include "base/Range.h" |
602d9612 | 13 | #include "splay.h" |
4c50505b | 14 | |
528b2c61 | 15 | class mem_node; |
62e76326 | 16 | |
528b2c61 | 17 | class StoreIOBuffer; |
62e76326 | 18 | |
19 | class mem_hdr | |
20 | { | |
21 | ||
528b2c61 | 22 | public: |
4c50505b | 23 | mem_hdr(); |
24 | ~mem_hdr(); | |
528b2c61 | 25 | void freeContent(); |
47f6e231 | 26 | int64_t lowestOffset () const; |
27 | int64_t endOffset () const; | |
28 | int64_t freeDataUpto (int64_t); | |
90703668 | 29 | ssize_t copy (StoreIOBuffer const &) const; |
47f6e231 | 30 | bool hasContigousContentRange(Range<int64_t> const &range) const; |
528b2c61 | 31 | /* success or fail */ |
32 | bool write (StoreIOBuffer const &); | |
42a503bd | 33 | void dump() const; |
34 | size_t size() const; | |
35 | /* Not an iterator - thus the start, not begin() */ | |
36 | mem_node const *start() const; | |
47f6e231 | 37 | mem_node *getBlockContainingLocation (int64_t location) const; |
ccd33084 | 38 | /* access the contained nodes - easier than punning |
26ac0430 | 39 | * as a contianer ourselves |
ccd33084 | 40 | */ |
41 | const Splay<mem_node *> &getNodes() const; | |
d06925a4 | 42 | char * NodeGet(mem_node * aNode); |
528b2c61 | 43 | |
44 | /* Only for use of MemObject */ | |
45 | void internalAppend(const char *data, int len); | |
42a503bd | 46 | |
552ec743 | 47 | static Splay<mem_node *>::SPLAYCMP NodeCompare; |
62e76326 | 48 | |
528b2c61 | 49 | private: |
b8bad68c | 50 | void debugDump() const; |
12d74f96 | 51 | bool unlink(mem_node *aNode); |
528b2c61 | 52 | void makeAppendSpace(); |
53 | int appendToNode(mem_node *aNode, const char *data, int maxLength); | |
54 | void appendNode (mem_node *aNode); | |
47f6e231 | 55 | size_t copyAvailable(mem_node *aNode, int64_t location, size_t amount, char *target) const; |
528b2c61 | 56 | bool unionNotEmpty (StoreIOBuffer const &); |
47f6e231 | 57 | mem_node *nodeToRecieve(int64_t offset); |
58 | size_t writeAvailable(mem_node *aNode, int64_t location, size_t amount, char const *source); | |
59 | int64_t inmem_hi; | |
42a503bd | 60 | Splay<mem_node *> nodes; |
528b2c61 | 61 | }; |
62 | ||
63 | #endif /* SQUID_STMEM_H */ | |
f53969cc | 64 |