5 typedef struct T___(_PH_CIRCULAR_BUFFER,
T)
8 #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE
14 }
T___(PH_CIRCULAR_BUFFER,
T), *
T___(PPH_CIRCULAR_BUFFER,
T);
19 T___(PhInitializeCircularBuffer,
T)(
20 _Out_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
27 T___(PhDeleteCircularBuffer,
T)(
28 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer
34 T___(PhResizeCircularBuffer,
T)(
35 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
42 T___(PhClearCircularBuffer,
T)(
43 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer
49 T___(PhCopyCircularBuffer,
T)(
50 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
51 _Out_writes_(Count)
T *Destination,
55 FORCEINLINE
T T___(PhGetItemCircularBuffer,
T)(
56 _In_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
60 #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE
61 return Buffer->Data[(Buffer->Index + Index) & Buffer->SizeMinusOne];
67 return Buffer->Data[(((Buffer->Index + Index) % size) + size) % size];
71 FORCEINLINE
VOID T___(PhSetItemCircularBuffer,
T)(
72 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
77 #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE
78 Buffer->Data[(Buffer->Index + Index) & Buffer->SizeMinusOne] = Value;
83 Buffer->Data[(((Buffer->Index + Index) % size) + size) % size] = Value;
87 FORCEINLINE
VOID T___(PhAddItemCircularBuffer,
T)(
88 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
92 #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE
93 Buffer->Data[Buffer->Index = ((Buffer->Index - 1) & Buffer->SizeMinusOne)] = Value;
98 Buffer->Data[Buffer->Index = (((Buffer->Index - 1) % size) + size) % size] = Value;
101 if (Buffer->Count < Buffer->Size)
105 FORCEINLINE
T T___(PhAddItemCircularBuffer2,
T)(
106 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
113 #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE
114 index = ((Buffer->Index - 1) & Buffer->SizeMinusOne);
119 index = (((Buffer->Index - 1) % size) + size) % size;
122 Buffer->Index = index;
123 oldValue = Buffer->Data[index];
124 Buffer->Data[index] = Value;
126 if (Buffer->Count < Buffer->Size)