16 #include <gtest/gtest.h>
31 for (
int iter = 0; iter < 2; ++iter) {
33 for (
int i = 0; i < 768; ++i) {
121 for (
int i = 0; i < 1024; ++i) {
129 for (
int i = 0; i < 1024; ++i) {
136 for (
int i = 0; i < 1024; ++i) {
179 memset(ptr, 0, 1024);
184 EXPECT_TRUE(ptr == ptr2);
189 EXPECT_TRUE(ptr2 == ptr + 8);
191 memset(ptr2, 1, 1016 - 512);
195 EXPECT_TRUE(ptr3 == ptr + 512);
196 memset(ptr3, 2, 512);
198 for (
int i = 0; i < 8; ++i) {
199 EXPECT_EQ(ptr[i], 0);
201 for (
int i = 8; i < 512; ++i) {
202 EXPECT_EQ(ptr[i], 1);
204 for (
int i = 512; i < 1024; ++i) {
205 EXPECT_EQ(ptr[i], 2);
266 uint8_t* result = p2->TryAllocate(160);
267 DCHECK(result != NULL);
271 result = p2->TryAllocate(160);
272 DCHECK(result == NULL);
277 result = p2->TryAllocate(20);
278 DCHECK(result != NULL);
288 int main(
int argc,
char **argv) {
289 ::testing::InitGoogleTest(&argc, argv);
290 return RUN_ALL_TESTS();
bool CheckIntegrity(bool current_chunk_empty)
int main(int argc, char **argv)
int64_t consumption() const
Returns the memory consumed in bytes.
int64_t peak_allocated_bytes() const
uint8_t * GetDataPtr(int offset)
int64_t total_allocated_bytes() const
int64_t GetTotalChunkSizes() const
Return sum of chunk_sizes_.
void AcquireData(MemPool *src, bool keep_current)
void Clear()
Makes all allocated chunks available for re-use, but doesn't delete any chunks.
void ReturnPartialAllocation(int byte_size)
int GetCurrentOffset() const
This class is thread-safe.
uint8_t offset[7 *64-sizeof(uint64_t)]
int GetOffset(uint8_t *data)
static bool CheckIntegrity(MemPool *pool, bool current_chunk_empty)
uint8_t * Allocate(int size)