- CItemBuffer: - Rename CItemBufferCore -> CItemBuffer - Add item count and GetCount() method - Bug fix: Reset LastItem on DeleteAll() - TimingCore: - Bug fix: Handle buffer overflow on 32-bit processors
71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
/*
|
|
* BufferCore.h
|
|
*
|
|
* Created on: 22 July 2017
|
|
* Author: wentzelc
|
|
*/
|
|
|
|
#ifndef REDACORE_ITEMBUFFERCORE_H_
|
|
#define REDACORE_ITEMBUFFERCORE_H_
|
|
|
|
// Standard C/C++ Libraries
|
|
#include <stdlib.h>
|
|
|
|
// redA Libraries
|
|
/* none */
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//***** Data Structures *****//
|
|
|
|
typedef struct SBufferItem TBufferItem;
|
|
|
|
struct SBufferItem {
|
|
void * Entry;
|
|
int Size;
|
|
|
|
TBufferItem * NextItem;
|
|
};
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//***** Function Prototypes *****//
|
|
|
|
class CItemBuffer
|
|
{
|
|
protected:
|
|
// Parameters
|
|
bool CopyEntries; // Make copies of entries and destroy them when done?
|
|
int Count;
|
|
|
|
// Items
|
|
TBufferItem * FirstItem;
|
|
TBufferItem ** LastItem;
|
|
|
|
// Item Life cycle
|
|
TBufferItem * CreateItem( void * Entry, int Size );
|
|
bool DestroyItem( TBufferItem ** BufferItem );
|
|
|
|
virtual bool DestroyEntry( void ** Entry );
|
|
|
|
public:
|
|
// Initiate object
|
|
CItemBuffer( bool pCopyEntries );
|
|
virtual ~CItemBuffer();
|
|
|
|
// Buffer Operations
|
|
bool Push( void * Entry, int Size );
|
|
void * Pop( int * Size = NULL );
|
|
void * Peek( int * Size = NULL );
|
|
bool Delete();
|
|
void DeleteAll();
|
|
|
|
// Misc
|
|
int GetCount() { return Count; };
|
|
};
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#endif /* REDACORE_ITEMBUFFERCORE_H_ */
|
|
|