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
74536d7a
Commit
74536d7a
authored
Nov 28, 2018
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libcnary: Remove redundant members from node_t struct
parent
2e67a01b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
32 deletions
+17
-32
node.h
libcnary/include/node.h
+0
-10
node.c
libcnary/node.c
+17
-22
No files found.
libcnary/include/node.h
View file @
74536d7a
...
...
@@ -37,20 +37,10 @@ typedef struct node_t {
struct
node_t
*
prev
;
unsigned
int
count
;
// Local Properties
int
isRoot
;
int
isLeaf
;
// Local Members
void
*
data
;
unsigned
int
depth
;
struct
node_t
*
parent
;
struct
node_list_t
*
children
;
// Virtual Functions
int
(
*
attach
)(
struct
node_t
*
parent
,
struct
node_t
*
child
);
int
(
*
detach
)(
struct
node_t
*
parent
,
struct
node_t
*
child
);
}
node_t
;
void
node_destroy
(
struct
node_t
*
node
);
...
...
libcnary/node.c
View file @
74536d7a
...
...
@@ -54,14 +54,11 @@ node_t* node_create(node_t* parent, void* data) {
memset
(
node
,
'\0'
,
sizeof
(
node_t
));
node
->
data
=
data
;
node
->
depth
=
0
;
node
->
next
=
NULL
;
node
->
prev
=
NULL
;
node
->
count
=
0
;
node
->
isLeaf
=
TRUE
;
node
->
isRoot
=
TRUE
;
node
->
parent
=
NULL
;
node
->
children
=
node_list_create
()
;
node
->
children
=
NULL
;
// Pass NULL to create a root node
if
(
parent
!=
NULL
)
{
...
...
@@ -80,12 +77,9 @@ node_t* node_create(node_t* parent, void* data) {
int
node_attach
(
node_t
*
parent
,
node_t
*
child
)
{
if
(
!
parent
||
!
child
)
return
-
1
;
child
->
isLeaf
=
TRUE
;
child
->
isRoot
=
FALSE
;
child
->
parent
=
parent
;
child
->
depth
=
parent
->
depth
+
1
;
if
(
parent
->
isLeaf
==
TRUE
)
{
parent
->
isLeaf
=
FALSE
;
if
(
!
parent
->
children
)
{
parent
->
children
=
node_list_create
();
}
int
res
=
node_list_add
(
parent
->
children
,
child
);
if
(
res
==
0
)
{
...
...
@@ -106,12 +100,9 @@ int node_detach(node_t* parent, node_t* child) {
int
node_insert
(
node_t
*
parent
,
unsigned
int
node_index
,
node_t
*
child
)
{
if
(
!
parent
||
!
child
)
return
-
1
;
child
->
isLeaf
=
TRUE
;
child
->
isRoot
=
FALSE
;
child
->
parent
=
parent
;
child
->
depth
=
parent
->
depth
+
1
;
if
(
parent
->
isLeaf
==
TRUE
)
{
parent
->
isLeaf
=
FALSE
;
if
(
!
parent
->
children
)
{
parent
->
children
=
node_list_create
();
}
int
res
=
node_list_insert
(
parent
->
children
,
node_index
,
child
);
if
(
res
==
0
)
{
...
...
@@ -120,33 +111,37 @@ int node_insert(node_t* parent, unsigned int node_index, node_t* child)
return
res
;
}
void
node_debug
(
node_t
*
node
)
{
static
void
_node_debug
(
node_t
*
node
,
unsigned
int
depth
)
{
unsigned
int
i
=
0
;
node_t
*
current
=
NULL
;
node_iterator_t
*
iter
=
NULL
;
for
(
i
=
0
;
i
<
node
->
depth
;
i
++
)
{
for
(
i
=
0
;
i
<
depth
;
i
++
)
{
printf
(
"
\t
"
);
}
if
(
node
->
isRoo
t
)
{
if
(
!
node
->
paren
t
)
{
printf
(
"ROOT
\n
"
);
}
if
(
node
->
isLeaf
&&
!
node
->
isRoo
t
)
{
if
(
!
node
->
children
&&
node
->
paren
t
)
{
printf
(
"LEAF
\n
"
);
}
else
{
if
(
!
node
->
isRoo
t
)
{
if
(
node
->
paren
t
)
{
printf
(
"NODE
\n
"
);
}
iter
=
node_iterator_create
(
node
->
children
);
for
(
current
=
iter
->
begin
;
current
!=
NULL
;
current
=
iter
->
next
(
iter
))
{
node_debug
(
current
);
while
((
current
=
iter
->
next
(
iter
)
))
{
_node_debug
(
current
,
depth
+
1
);
}
node_iterator_destroy
(
iter
);
}
}
void
node_debug
(
node_t
*
node
)
{
_node_debug
(
node
,
0
);
}
unsigned
int
node_n_children
(
struct
node_t
*
node
)
{
if
(
!
node
)
return
0
;
...
...
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