summaryrefslogtreecommitdiff
path: root/testing/test_support.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-06 10:16:32 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-06 10:16:32 -0800
commit0aa3531a87dde44ffd90416f6d621b1828edaf22 (patch)
tree9b5f0e12a5e1aec13fd3d4f0242efcc6834d830e /testing/test_support.h
parentd483eb46d8920547d1b47351e65fa0299eaba191 (diff)
downloadpdfium-0aa3531a87dde44ffd90416f6d621b1828edaf22.tar.xz
Merge to XFA: Return unique_ptrs from test_support functions
Orignal Review URL: https://codereview.chromium.org/1563513002 . (cherry picked from commit aa326bd6b169dc1b5b9b83048c71799799ab34c6) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1564583004 .
Diffstat (limited to 'testing/test_support.h')
-rw-r--r--testing/test_support.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/testing/test_support.h b/testing/test_support.h
index d48d5596f4..945704194d 100644
--- a/testing/test_support.h
+++ b/testing/test_support.h
@@ -6,6 +6,7 @@
#define TESTING_EMBEDDER_TEST_SUPPORT_H_
#include <stdlib.h>
+#include <memory>
#include <string>
#include "public/fpdfview.h"
@@ -14,16 +15,27 @@
#include "v8/include/v8.h"
#endif // PDF_ENABLE_V8
-// Reads the entire contents of a file into a newly malloc'd buffer.
-char* GetFileContents(const char* filename, size_t* retlen);
+namespace pdfium {
+
+// Used with std::unique_ptr to free() objects that can't be deleted.
+struct FreeDeleter {
+ inline void operator()(void* ptr) const { free(ptr); }
+};
+
+} // namespace pdfium
+
+// Reads the entire contents of a file into a newly alloc'd buffer.
+std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename,
+ size_t* retlen);
// Converts a FPDF_WIDESTRING to a std::wstring.
// Deals with differences between UTF16LE and wchar_t.
std::wstring GetPlatformWString(const FPDF_WIDESTRING wstr);
-// Returns a newly mallocated FPDF_WIDESTRING (caller must free()).
+// Returns a newly allocated FPDF_WIDESTRING.
// Deals with differences between UTF16LE and wchar_t.
-FPDF_WIDESTRING GetFPDFWideString(const std::wstring& wstr);
+std::unique_ptr<unsigned short, pdfium::FreeDeleter> GetFPDFWideString(
+ const std::wstring& wstr);
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA