Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwn
libplist
Commits
34438457
Commit
34438457
authored
6 years ago
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpp: Dictionary: Reduce code duplication with helper function
parent
84d6af8f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
47 deletions
+16
-47
Dictionary.cpp
src/Dictionary.cpp
+16
-47
No files found.
src/Dictionary.cpp
View file @
34438457
...
@@ -28,27 +28,28 @@ Dictionary::Dictionary(Node* parent) : Structure(PLIST_DICT, parent)
...
@@ -28,27 +28,28 @@ Dictionary::Dictionary(Node* parent) : Structure(PLIST_DICT, parent)
{
{
}
}
Dictionary
::
Dictionary
(
plist_t
node
,
Node
*
parent
)
:
Structure
(
parent
)
static
void
dictionary_fill
(
Dictionary
*
_this
,
std
::
map
<
std
::
string
,
Node
*>
map
,
plist_t
node
)
{
{
_node
=
node
;
plist_dict_iter
it
=
NULL
;
plist_dict_iter
it
=
NULL
;
plist_dict_new_iter
(
node
,
&
it
);
char
*
key
=
NULL
;
plist_t
subnode
=
NULL
;
plist_t
subnode
=
NULL
;
plist_dict_new_iter
(
_node
,
&
it
);
do
{
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
char
*
key
=
NULL
;
while
(
subnode
)
{
_map
[
std
::
string
(
key
)]
=
Node
::
FromPlist
(
subnode
,
this
);
subnode
=
NULL
;
subnode
=
NULL
;
plist_dict_next_item
(
node
,
it
,
&
key
,
&
subnode
);
if
(
key
&&
subnode
)
map
[
std
::
string
(
key
)]
=
Node
::
FromPlist
(
subnode
,
_this
);
free
(
key
);
free
(
key
);
key
=
NULL
;
}
while
(
subnode
);
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
}
free
(
it
);
free
(
it
);
}
}
Dictionary
::
Dictionary
(
plist_t
node
,
Node
*
parent
)
:
Structure
(
parent
)
{
_node
=
node
;
dictionary_fill
(
this
,
_map
,
_node
);
}
Dictionary
::
Dictionary
(
const
PList
::
Dictionary
&
d
)
:
Structure
()
Dictionary
::
Dictionary
(
const
PList
::
Dictionary
&
d
)
:
Structure
()
{
{
for
(
Dictionary
::
iterator
it
=
_map
.
begin
();
it
!=
_map
.
end
();
it
++
)
for
(
Dictionary
::
iterator
it
=
_map
.
begin
();
it
!=
_map
.
end
();
it
++
)
...
@@ -57,24 +58,8 @@ Dictionary::Dictionary(const PList::Dictionary& d) : Structure()
...
@@ -57,24 +58,8 @@ Dictionary::Dictionary(const PList::Dictionary& d) : Structure()
delete
it
->
second
;
delete
it
->
second
;
}
}
_map
.
clear
();
_map
.
clear
();
_node
=
plist_copy
(
d
.
GetPlist
());
_node
=
plist_copy
(
d
.
GetPlist
());
plist_dict_iter
it
=
NULL
;
dictionary_fill
(
this
,
_map
,
_node
);
char
*
key
=
NULL
;
plist_t
subnode
=
NULL
;
plist_dict_new_iter
(
_node
,
&
it
);
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
while
(
subnode
)
{
_map
[
std
::
string
(
key
)]
=
Node
::
FromPlist
(
subnode
,
this
);
subnode
=
NULL
;
free
(
key
);
key
=
NULL
;
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
}
free
(
it
);
}
}
Dictionary
&
Dictionary
::
operator
=
(
PList
::
Dictionary
&
d
)
Dictionary
&
Dictionary
::
operator
=
(
PList
::
Dictionary
&
d
)
...
@@ -85,24 +70,8 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
...
@@ -85,24 +70,8 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
delete
it
->
second
;
delete
it
->
second
;
}
}
_map
.
clear
();
_map
.
clear
();
_node
=
plist_copy
(
d
.
GetPlist
());
_node
=
plist_copy
(
d
.
GetPlist
());
plist_dict_iter
it
=
NULL
;
dictionary_fill
(
this
,
_map
,
_node
);
char
*
key
=
NULL
;
plist_t
subnode
=
NULL
;
plist_dict_new_iter
(
_node
,
&
it
);
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
while
(
subnode
)
{
_map
[
std
::
string
(
key
)]
=
Node
::
FromPlist
(
subnode
,
this
);
subnode
=
NULL
;
free
(
key
);
key
=
NULL
;
plist_dict_next_item
(
_node
,
it
,
NULL
,
&
subnode
);
}
free
(
it
);
return
*
this
;
return
*
this
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment