summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSune Vuorela <sune@vuorela.dk>2024-12-19 13:13:55 +0100
committerAlbert Astals Cid <aacid@kde.org>2024-12-20 09:44:09 +0000
commit1509b915ef1c826d40b6dccabb7f1fabf62e5f84 (patch)
treee8ca38fddf304f84688251c6f0c1f800bd71c35a
parent382908d6431dbd2f8cfa612fed998a0872a3ced8 (diff)
Form: remove grealloc in favor of a vector
-rw-r--r--poppler/Form.cc13
-rw-r--r--poppler/Form.h8
2 files changed, 5 insertions, 16 deletions
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 4440bd44..6e351070 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -51,7 +51,6 @@
#include <cstring>
#include <cctype>
#include "goo/ft_utils.h"
-#include "goo/gmem.h"
#include "goo/gfile.h"
#include "goo/GooString.h"
#include "Error.h"
@@ -1410,8 +1409,6 @@ FormFieldButton::FormFieldButton(PDFDoc *docA, Object &&dictObj, const Ref refA,
Dict *dict = obj.getDict();
active_child = -1;
noAllOff = false;
- siblings = nullptr;
- numSiblings = 0;
appearanceState.setToNull();
defaultAppearanceState.setToNull();
@@ -1466,8 +1463,7 @@ void FormFieldButton::print(int indent)
void FormFieldButton::setNumSiblings(int num)
{
- numSiblings = num;
- siblings = (FormFieldButton **)greallocn(static_cast<void *>(siblings), numSiblings, sizeof(FormFieldButton *));
+ siblings.resize(num, nullptr);
}
void FormFieldButton::fillChildrenSiblingsID()
@@ -1580,12 +1576,7 @@ void FormFieldButton::updateState(const char *state)
xref->setModifiedObject(&obj, ref);
}
-FormFieldButton::~FormFieldButton()
-{
- if (siblings) {
- gfree(static_cast<void *>(siblings));
- }
-}
+FormFieldButton::~FormFieldButton() = default;
void FormFieldButton::reset(const std::vector<std::string> &excludedFields)
{
diff --git a/poppler/Form.h b/poppler/Form.h
index cb6620a6..7a1e49cc 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -459,7 +459,7 @@ public:
// For radio buttons, return the fields of the other radio buttons in the same group
FormFieldButton *getSibling(int i) const { return siblings[i]; }
- int getNumSiblings() const { return numSiblings; }
+ int getNumSiblings() const { return int(siblings.size()); }
void print(int indent) override;
void reset(const std::vector<std::string> &excludedFields) override;
@@ -469,10 +469,8 @@ public:
protected:
void updateState(const char *state);
- FormFieldButton **siblings; // IDs of dependent buttons (each button of a radio field has all the others buttons
- // of the same field in this array)
- int numSiblings;
-
+ std::vector<FormFieldButton *> siblings; // IDs of dependent buttons (each button of a radio field has all the others buttons
+ // of the same field in this array)
FormButtonType btype;
int size;
int active_child; // only used for combo box