MCPcopy Create free account
hub / github.com/apache/trafficserver / fillCache

Function fillCache

src/iocore/hostdb/test_RefCountCache.cc:85–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83std::set<ExampleStruct *> ExampleStruct::items_freed;
84
85void
86fillCache(RefCountCache<ExampleStruct> *cache, int start, int end)
87{
88 // TODO: name per?
89 std::string name = "foobar";
90 int allocSize = name.size() + 1;
91
92 for (int i = start; i < end; i++) {
93 ExampleStruct *tmp = ExampleStruct::alloc(allocSize);
94 cache->put(static_cast<uint64_t>(i), tmp);
95
96 tmp->idx = i;
97 tmp->name_offset = sizeof(ExampleStruct);
98 memcpy(tmp->name(), name.c_str(), name.size());
99 // nullptr terminate the string
100 *(tmp->name() + name.size()) = '\0';
101
102 // Print out the struct we put in there
103 // printf("New ExampleStruct%d idx=%d name=%s allocSize=%d\n", i, tmp->idx, name.c_str(), allocSize);
104 }
105 printf("Loading complete! Cache now has %ld items.\n\n", cache->count());
106}
107
108int
109verifyCache(RefCountCache<ExampleStruct> *cache, int start, int end)

Callers 1

testFunction · 0.85

Calls 6

memcpyFunction · 0.50
sizeMethod · 0.45
putMethod · 0.45
nameMethod · 0.45
c_strMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected