summaryrefslogtreecommitdiff
path: root/tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools.h')
-rw-r--r--tools.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/tools.h b/tools.h
index f2ba3157..73cca5a3 100644
--- a/tools.h
+++ b/tools.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.h 4.4 2016/12/13 12:13:46 kls Exp $
+ * $Id: tools.h 4.5 2016/12/23 13:56:35 kls Exp $
*/
#ifndef __TOOLS_H
@@ -775,6 +775,26 @@ public:
bool Load(const char *Directory, bool DirsOnly = false);
};
+class cDynamicBuffer {
+private:
+ uchar *buffer;
+ int initialSize;
+ int size; // the total size of the buffer (bytes in memory)
+ int used; // the number of used bytes, starting at the beginning of the buffer
+ bool Realloc(int NewSize);
+ bool Assert(int NewSize) { return size < NewSize ? Realloc(NewSize) : true; } // inline for performance!
+public:
+ cDynamicBuffer(int InitialSize = 1024);
+ ~cDynamicBuffer();
+ void Append(const uchar *Data, int Length);
+ void Append(uchar Data) { if (Assert(used + 1)) buffer[used++] = Data; }
+ void Set(int Index, uchar Data) { if (Assert(Index + 1)) buffer[Index] = Data; }
+ uchar Get(int Index) { return Index < used ? buffer[Index] : 0; }
+ void Clear(void) { used = 0; }
+ uchar *Data(void) { return buffer; }
+ int Length(void) { return used; }
+ };
+
class cHashObject : public cListObject {
friend class cHashBase;
private: