Commit ffe26edc authored by Adrien Conrath's avatar Adrien Conrath Committed by facebook-github-bot-0

Remove undefined behavior in goodMallocSize()

Reviewed By: ot

Differential Revision: D2695741

fb-gh-sync-id: d33263c1ffa5651d66f37992ce365dae157ed449
parent 5d820ea6
......@@ -177,6 +177,10 @@ inline bool usingJEMalloc() noexcept {
}
inline size_t goodMallocSize(size_t minSize) noexcept {
if (minSize == 0) {
return 0;
}
if (!usingJEMalloc()) {
// Not using jemalloc - no smarts
return minSize;
......
......@@ -274,6 +274,16 @@ TEST(FBVector, vector_of_maps) {
EXPECT_EQ(1, v[1].size());
}
TEST(FBVector, shrink_to_fit_after_clear) {
fbvector<int> fb1;
fb1.push_back(42);
fb1.push_back(1337);
fb1.clear();
fb1.shrink_to_fit();
EXPECT_EQ(fb1.size(), 0);
EXPECT_EQ(fb1.capacity(), 0);
}
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
gflags::ParseCommandLineFlags(&argc, &argv, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment