summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_stitchfunc.cpp23
-rw-r--r--core/fpdfapi/page/cpdf_stitchfunc.h6
2 files changed, 13 insertions, 16 deletions
diff --git a/core/fpdfapi/page/cpdf_stitchfunc.cpp b/core/fpdfapi/page/cpdf_stitchfunc.cpp
index 1e5329b337..aed17828d9 100644
--- a/core/fpdfapi/page/cpdf_stitchfunc.cpp
+++ b/core/fpdfapi/page/cpdf_stitchfunc.cpp
@@ -20,10 +20,7 @@ constexpr uint32_t kRequiredNumInputs = 1;
CPDF_StitchFunc::CPDF_StitchFunc() : CPDF_Function(Type::kType3Stitching) {}
-CPDF_StitchFunc::~CPDF_StitchFunc() {
- FX_Free(m_pBounds);
- FX_Free(m_pEncode);
-}
+CPDF_StitchFunc::~CPDF_StitchFunc() {}
bool CPDF_StitchFunc::v_Init(CPDF_Object* pObj,
std::set<CPDF_Object*>* pVisited) {
@@ -98,15 +95,15 @@ bool CPDF_StitchFunc::v_Init(CPDF_Object* pObj,
m_nOutputs = *nOutputs;
}
- m_pBounds = FX_Alloc(float, nSubs + 1);
- m_pBounds[0] = m_pDomains[0];
+ m_bounds.reserve(nSubs + 1);
+ m_bounds.push_back(m_pDomains[0]);
for (uint32_t i = 0; i < nSubs - 1; i++)
- m_pBounds[i + 1] = pBoundsArray->GetFloatAt(i);
- m_pBounds[nSubs] = m_pDomains[1];
+ m_bounds.push_back(pBoundsArray->GetFloatAt(i));
+ m_bounds.push_back(m_pDomains[1]);
- m_pEncode = FX_Alloc2D(float, nSubs, 2);
+ m_encode.reserve(nSubs * 2);
for (uint32_t i = 0; i < nSubs * 2; i++)
- m_pEncode[i] = pEncodeArray->GetFloatAt(i);
+ m_encode.push_back(pEncodeArray->GetFloatAt(i));
return true;
}
@@ -114,11 +111,11 @@ bool CPDF_StitchFunc::v_Call(const float* inputs, float* results) const {
float input = inputs[0];
size_t i;
for (i = 0; i < m_pSubFunctions.size() - 1; i++) {
- if (input < m_pBounds[i + 1])
+ if (input < m_bounds[i + 1])
break;
}
- input = Interpolate(input, m_pBounds[i], m_pBounds[i + 1], m_pEncode[i * 2],
- m_pEncode[i * 2 + 1]);
+ input = Interpolate(input, m_bounds[i], m_bounds[i + 1], m_encode[i * 2],
+ m_encode[i * 2 + 1]);
int nresults;
return m_pSubFunctions[i]->Call(&input, kRequiredNumInputs, results,
&nresults);
diff --git a/core/fpdfapi/page/cpdf_stitchfunc.h b/core/fpdfapi/page/cpdf_stitchfunc.h
index 360b789072..d6dd63d2d5 100644
--- a/core/fpdfapi/page/cpdf_stitchfunc.h
+++ b/core/fpdfapi/page/cpdf_stitchfunc.h
@@ -25,12 +25,12 @@ class CPDF_StitchFunc : public CPDF_Function {
const std::vector<std::unique_ptr<CPDF_Function>>& GetSubFunctions() const {
return m_pSubFunctions;
}
- float GetBound(size_t i) const { return m_pBounds[i]; }
+ float GetBound(size_t i) const { return m_bounds[i]; }
private:
std::vector<std::unique_ptr<CPDF_Function>> m_pSubFunctions;
- float* m_pBounds = nullptr;
- float* m_pEncode = nullptr;
+ std::vector<float> m_bounds;
+ std::vector<float> m_encode;
};
#endif // CORE_FPDFAPI_PAGE_CPDF_STITCHFUNC_H_