summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-16 13:22:47 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-16 22:17:03 +0000
commit1d17a047db12530f28f4b5e22a9c5bd175af641f (patch)
treee7490e0a6cfc78179664480bdbb64ae9b6bb07ea /public
parent939121f33f9bb02c207094b5b3e78e69be992b84 (diff)
downloadpdfium-1d17a047db12530f28f4b5e22a9c5bd175af641f.tar.xz
Introduce unique_ptr compatible deleters for FPDF typeschromium/3044
Pre-requisite for easily fixing some leaks in sample code, fuzzers, etc. Kill off some types completely unused in the C API. Change-Id: I67f0a5c6eef63d8e062ca4bc97c9db03970fe337 Reviewed-on: https://pdfium-review.googlesource.com/3095 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'public')
-rw-r--r--public/cpp/fpdf_deleters.h41
-rw-r--r--public/fpdfview.h4
2 files changed, 41 insertions, 4 deletions
diff --git a/public/cpp/fpdf_deleters.h b/public/cpp/fpdf_deleters.h
new file mode 100644
index 0000000000..6754902a77
--- /dev/null
+++ b/public/cpp/fpdf_deleters.h
@@ -0,0 +1,41 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PUBLIC_CPP_FPDF_DELETERS_H_
+#define PUBLIC_CPP_FPDF_DELETERS_H_
+
+#include "public/fpdf_dataavail.h"
+#include "public/fpdf_formfill.h"
+#include "public/fpdf_text.h"
+#include "public/fpdfview.h"
+
+// Custom deleters for using FPDF_* types with std::unique_ptr<>.
+
+struct FPDFAvailDeleter {
+ inline void operator()(FPDF_AVAIL avail) { FPDFAvail_Destroy(avail); }
+};
+
+struct FPDFBitmapDeleter {
+ inline void operator()(FPDF_BITMAP bitmap) { FPDFBitmap_Destroy(bitmap); }
+};
+
+struct FPDFDocumentDeleter {
+ inline void operator()(FPDF_DOCUMENT doc) { FPDF_CloseDocument(doc); }
+};
+
+struct FPDFFormHandleDeleter {
+ inline void operator()(FPDF_FORMHANDLE form) {
+ FPDFDOC_ExitFormFillEnvironment(form);
+ }
+};
+
+struct FPDFTextPageDeleter {
+ inline void operator()(FPDF_TEXTPAGE text) { FPDFText_ClosePage(text); }
+};
+
+struct FPDFPageDeleter {
+ inline void operator()(FPDF_PAGE page) { FPDF_ClosePage(page); }
+};
+
+#endif // PUBLIC_CPP_FPDF_DELETERS_H_
diff --git a/public/fpdfview.h b/public/fpdfview.h
index 1c47a366bd..0ed9187f35 100644
--- a/public/fpdfview.h
+++ b/public/fpdfview.h
@@ -26,17 +26,13 @@ typedef void* FPDF_BITMAP;
typedef void* FPDF_BOOKMARK;
typedef void* FPDF_CLIPPATH;
typedef void* FPDF_DEST;
-typedef void* FPDF_DOCSCHHANDLE;
typedef void* FPDF_DOCUMENT;
typedef void* FPDF_FONT;
-typedef void* FPDF_HMODULE;
typedef void* FPDF_LINK;
-typedef void* FPDF_MODULEMGR;
typedef void* FPDF_PAGE;
typedef void* FPDF_PAGELINK;
typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
typedef void* FPDF_PAGERANGE;
-typedef void* FPDF_PATH;
typedef void* FPDF_RECORDER;
typedef void* FPDF_SCHHANDLE;
typedef void* FPDF_STRUCTELEMENT;