Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: core/fpdfapi/fpdf_page/include/cpdf_colorspace.h

Issue 2368433003: Make CPDF_ColorSpace::Load() return a unique_ptr (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_doc.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h b/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
index fc0433f52ffb1c6bd0caf48ce551a5a93200075b..2166f9b3a8390785590f20020255c591b9e754ed 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_
#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_
+#include <memory>
+
#include "core/fxcrt/include/cfx_weak_ptr.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
@@ -30,10 +32,11 @@ class CPDF_Object;
class CPDF_ColorSpace {
public:
static CPDF_ColorSpace* GetStockCS(int Family);
- static CPDF_ColorSpace* Load(CPDF_Document* pDoc, CPDF_Object* pCSObj);
static CPDF_ColorSpace* ColorspaceFromName(const CFX_ByteString& name);
+ static std::unique_ptr<CPDF_ColorSpace> Load(CPDF_Document* pDoc,
+ CPDF_Object* pCSObj);
- void ReleaseCS();
+ void Release();
int GetBufSize() const;
FX_FLOAT* CreateBuf();
@@ -104,4 +107,18 @@ class CPDF_ColorSpace {
using CPDF_CountedColorSpace = CFX_WeakPtr<CPDF_ColorSpace>::Handle;
+namespace std {
+
+// Make std::unique_ptr<CPDF_ColorSpace> call Release() rather than
+// simply deleting the object.
+template <>
+struct default_delete<CPDF_ColorSpace> {
Lei Zhang 2016/09/23 01:46:21 Neat. Maybe we can do that for CPDF_Object too.
+ void operator()(CPDF_ColorSpace* pColorSpace) const {
+ if (pColorSpace)
+ pColorSpace->Release();
+ }
+};
+
+} // namespace std
+
#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_doc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698