Use std::vector<> in testing/test_fonts.h
Remove last usage of the std::unique_ptr<T[]> anti-pattern in favor
of a type that knows its size.
Change-Id: Ic42e07c984314b0d52d402dc1ab8b936c552a99b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/115050
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/test_fonts.cpp b/testing/test_fonts.cpp
index 3a096a9..7807e04 100644
--- a/testing/test_fonts.cpp
+++ b/testing/test_fonts.cpp
@@ -4,6 +4,7 @@
#include "testing/test_fonts.h"
+#include <memory>
#include <set>
#include <utility>
@@ -96,9 +97,7 @@
return;
font_path_.push_back(PATH_SEPARATOR);
font_path_.append("test_fonts");
- font_paths_ = std::make_unique<const char*[]>(2);
- font_paths_[0] = font_path_.c_str();
- font_paths_[1] = nullptr;
+ font_paths_ = std::vector<const char*>{font_path_.c_str(), nullptr};
}
TestFonts::~TestFonts() = default;
diff --git a/testing/test_fonts.h b/testing/test_fonts.h
index 4e2a822..e266a3c 100644
--- a/testing/test_fonts.h
+++ b/testing/test_fonts.h
@@ -5,23 +5,22 @@
#ifndef TESTING_TEST_FONTS_H_
#define TESTING_TEST_FONTS_H_
-#include <memory>
#include <string>
+#include <vector>
class TestFonts {
public:
TestFonts();
~TestFonts();
- const char** font_paths() const { return font_paths_.get(); }
-
+ const char** font_paths() { return font_paths_.data(); }
void InstallFontMapper();
static std::string RenameFont(const char* face);
private:
std::string font_path_;
- std::unique_ptr<const char*[]> font_paths_;
+ std::vector<const char*> font_paths_;
};
#endif // TESTING_TEST_FONTS_H_