summaryrefslogtreecommitdiff
path: root/samples/pdfium_test_write_helper.cc
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-25 18:49:32 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-25 18:49:32 +0000
commite08d2b1fee0db40bac9538ca8b7be0a951675bd6 (patch)
tree81ded468a54adb247f46d7824632f6c4a537619c /samples/pdfium_test_write_helper.cc
parenteb3ec8f29846a5df67269a53ca94d1d740c84513 (diff)
downloadpdfium-e08d2b1fee0db40bac9538ca8b7be0a951675bd6.tar.xz
Introduce ScopedFPDF types in public/cpp/fpdf_scopers.h
Applies std::remove_ptr to the public API types so that we can deduce a correct unique ptr type no matter how that API might change away from void* usage. Creates shorter names for std::unique_ptr<std::remove_pointer<>, ...> Change-Id: I04a0ff43cb7d5a4d3867939a53a54c9cef00db86 Reviewed-on: https://pdfium-review.googlesource.com/31292 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'samples/pdfium_test_write_helper.cc')
-rw-r--r--samples/pdfium_test_write_helper.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/samples/pdfium_test_write_helper.cc b/samples/pdfium_test_write_helper.cc
index d061252e07..c436c97fbe 100644
--- a/samples/pdfium_test_write_helper.cc
+++ b/samples/pdfium_test_write_helper.cc
@@ -9,7 +9,7 @@
#include <memory>
#include <vector>
-#include "public/cpp/fpdf_deleters.h"
+#include "public/cpp/fpdf_scopers.h"
#include "public/fpdf_annot.h"
#include "public/fpdf_attachment.h"
#include "public/fpdf_edit.h"
@@ -215,7 +215,7 @@ void WriteText(FPDF_PAGE page, const char* pdf_name, int num) {
return;
}
- std::unique_ptr<void, FPDFTextPageDeleter> textpage(FPDFText_LoadPage(page));
+ ScopedFPDFTextPage textpage(FPDFText_LoadPage(page));
for (int i = 0; i < FPDFText_CountChars(textpage.get()); i++) {
uint32_t c = FPDFText_GetUnicode(textpage.get(), i);
if (fwrite(&c, sizeof(c), 1, fp) != 1) {
@@ -250,8 +250,7 @@ void WriteAnnot(FPDF_PAGE page, const char* pdf_name, int num) {
for (int i = 0; i < annot_count; ++i) {
// Retrieve the annotation object and its subtype.
fprintf(fp, "Annotation #%d:\n", i + 1);
- std::unique_ptr<void, FPDFAnnotationDeleter> annot(
- FPDFPage_GetAnnot(page, i));
+ ScopedFPDFAnnotation annot(FPDFPage_GetAnnot(page, i));
if (!annot) {
fprintf(fp, "Failed to retrieve annotation!\n\n");
continue;
@@ -579,8 +578,7 @@ void WriteImages(FPDF_PAGE page, const char* pdf_name, int page_num) {
if (FPDFPageObj_GetType(obj) != FPDF_PAGEOBJ_IMAGE)
continue;
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap(
- FPDFImageObj_GetBitmap(obj));
+ ScopedFPDFBitmap bitmap(FPDFImageObj_GetBitmap(obj));
if (!bitmap) {
fprintf(stderr, "Image object #%d on page #%d has an empty bitmap.\n",
i + 1, page_num + 1);