6 _Out_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
10 #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE
12 Buffer->SizeMinusOne = Buffer->Size - 1;
19 Buffer->Data = PhAllocate(
sizeof(
T) * Buffer->Size);
23 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer
30 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
38 #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE
43 if (NewSize == Buffer->Size)
46 newData = PhAllocate(
sizeof(
T) * NewSize);
47 tailSize = (ULONG)(Buffer->Size - Buffer->Index);
48 headSize = Buffer->Count - tailSize;
50 if (NewSize > Buffer->Size)
53 memcpy(newData, &Buffer->Data[Buffer->Index],
sizeof(
T) * tailSize);
54 memcpy(&newData[tailSize], Buffer->Data,
sizeof(
T) * headSize);
59 if (tailSize >= NewSize)
62 memcpy(newData, &Buffer->Data[Buffer->Index],
sizeof(
T) * NewSize);
68 memcpy(newData, &Buffer->Data[Buffer->Index],
sizeof(
T) * tailSize);
69 memcpy(&newData[tailSize], Buffer->Data,
sizeof(
T) * (NewSize - tailSize));
74 if (Buffer->Count > NewSize)
75 Buffer->Count = NewSize;
78 Buffer->Data = newData;
79 Buffer->Size = NewSize;
80 #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE
81 Buffer->SizeMinusOne = NewSize - 1;
86 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer
94 _Inout_
T___(PPH_CIRCULAR_BUFFER,
T) Buffer,
95 _Out_writes_(Count)
T *Destination,
102 tailSize = (ULONG)(Buffer->Size - Buffer->Index);
103 headSize = Buffer->Count - tailSize;
105 if (Count > Buffer->Count)
106 Count = Buffer->Count;
108 if (tailSize >= Count)
111 memcpy(Destination, &Buffer->Data[Buffer->Index],
sizeof(
T) * Count);
116 memcpy(Destination, &Buffer->Data[Buffer->Index],
sizeof(
T) * tailSize);
117 memcpy(&Destination[tailSize], Buffer->Data,
sizeof(
T) * (Count - tailSize));