Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
3186bfa5
Commit
3186bfa5
authored
1 year ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
remove HEAP memory usage
parent
7fa95f07
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib66/tree/tree_service_add.c
+25
-17
25 additions, 17 deletions
src/lib66/tree/tree_service_add.c
src/lib66/tree/tree_service_remove.c
+17
-17
17 additions, 17 deletions
src/lib66/tree/tree_service_remove.c
with
42 additions
and
34 deletions
src/lib66/tree/tree_service_add.c
+
25
−
17
View file @
3186bfa5
...
@@ -13,9 +13,7 @@
...
@@ -13,9 +13,7 @@
*/
*/
#include
<oblibs/log.h>
#include
<oblibs/log.h>
#include
<oblibs/sastr.h>
#include
<oblibs/stack.h>
#include
<skalibs/stralloc.h>
#include
<66/resolve.h>
#include
<66/resolve.h>
#include
<66/tree.h>
#include
<66/tree.h>
...
@@ -24,43 +22,53 @@ void tree_service_add(char const *base, char const *treename, char const *servic
...
@@ -24,43 +22,53 @@ void tree_service_add(char const *base, char const *treename, char const *servic
{
{
log_flow
()
;
log_flow
()
;
int
r
;
size_t
len
=
strlen
(
service
)
;
resolve_tree_t
tres
=
RESOLVE_TREE_ZERO
;
resolve_tree_t
tres
=
RESOLVE_TREE_ZERO
;
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_TREE
,
&
tres
)
;
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_TREE
,
&
tres
)
;
stralloc
sa
=
STRALLOC_ZERO
;
stack_ref
pstk
=
0
;
_init_stack_
(
stk
,
SS_MAX_SERVICE
*
SS_MAX_SERVICE_NAME
+
1
+
len
+
1
)
;
if
(
resolve_read_g
(
wres
,
base
,
treename
)
<=
0
)
if
(
resolve_read_g
(
wres
,
base
,
treename
)
<=
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"read resolve file of tree: "
,
treename
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"read resolve file of tree: "
,
treename
)
;
if
(
tres
.
ncontents
)
{
if
(
tres
.
ncontents
)
{
if
(
!
sastr_clean_string
(
&
sa
,
tres
.
sa
.
s
+
tres
.
contents
))
if
(
!
stack_convert_string
(
&
stk
,
tres
.
sa
.
s
+
tres
.
contents
,
strlen
(
tres
.
sa
.
s
+
tres
.
contents
)))
log_dieu
(
LOG_EXIT_SYS
,
"clean string"
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"convert string to stack"
)
;
if
(
stack_retrieve_element
(
&
stk
,
service
)
<
0
)
{
if
(
!
s
astr
_add_
strin
g
(
&
s
a
,
service
))
if
(
!
s
tack
_add_g
(
&
s
tk
,
service
))
log_dieu
(
LOG_EXIT_SYS
,
"
clean string"
)
;
log_dieu
sys
(
LOG_EXIT_SYS
,
"
add service: "
,
service
,
" to tree: "
,
treename
)
;
if
(
!
sastr_sortndrop_element
(
&
sa
))
tres
.
ncontents
++
;
log_dieu
(
LOG_EXIT_SYS
,
"sort string"
)
;
}
tres
.
ncontents
=
sastr_nelement
(
&
sa
)
;
if
(
!
stack_close
(
&
stk
))
log_dieusys
(
LOG_EXIT_SYS
,
"close stack"
)
;
}
else
{
}
else
{
if
(
!
s
astr
_add_
strin
g
(
&
s
a
,
service
))
if
(
!
s
tack
_add_g
(
&
s
tk
,
service
))
log_dieu
(
LOG_EXIT_SYS
,
"add string"
)
;
log_dieu
(
LOG_EXIT_SYS
,
"add string
to stack
"
)
;
tres
.
ncontents
++
;
tres
.
ncontents
++
;
if
(
!
stack_close
(
&
stk
))
log_dieusys
(
LOG_EXIT_SYS
,
"close stack"
)
;
}
}
if
(
!
s
astr_rebuild_in_onel
in
e
(
&
s
a
))
if
(
!
s
tack_convert_tostr
in
g
(
&
s
tk
))
log_dieu
(
LOG_EXIT_SYS
,
"
rebuild stralloc list
"
)
;
log_dieu
(
LOG_EXIT_SYS
,
"
convert stack to string
"
)
;
if
(
!
resolve_modify_field
(
wres
,
E_RESOLVE_TREE_CONTENTS
,
s
a
.
s
))
if
(
!
resolve_modify_field
(
wres
,
E_RESOLVE_TREE_CONTENTS
,
s
tk
.
s
))
log_dieusys
(
LOG_EXIT_SYS
,
"modify resolve file of: "
,
treename
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"modify resolve file of: "
,
treename
)
;
if
(
!
resolve_write_g
(
wres
,
base
,
treename
))
if
(
!
resolve_write_g
(
wres
,
base
,
treename
))
log_dieusys
(
LOG_EXIT_SYS
,
"write resolve file of tree: "
,
treename
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write resolve file of tree: "
,
treename
)
;
stralloc_free
(
&
sa
)
;
resolve_free
(
wres
)
;
resolve_free
(
wres
)
;
}
}
This diff is collapsed.
Click to expand it.
src/lib66/tree/tree_service_remove.c
+
17
−
17
View file @
3186bfa5
...
@@ -13,9 +13,7 @@
...
@@ -13,9 +13,7 @@
*/
*/
#include
<oblibs/log.h>
#include
<oblibs/log.h>
#include
<oblibs/sastr.h>
#include
<oblibs/stack.h>
#include
<skalibs/stralloc.h>
#include
<66/resolve.h>
#include
<66/resolve.h>
#include
<66/tree.h>
#include
<66/tree.h>
...
@@ -26,7 +24,6 @@ void tree_service_remove(char const *base, char const *treename, char const *ser
...
@@ -26,7 +24,6 @@ void tree_service_remove(char const *base, char const *treename, char const *ser
resolve_tree_t
tres
=
RESOLVE_TREE_ZERO
;
resolve_tree_t
tres
=
RESOLVE_TREE_ZERO
;
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_TREE
,
&
tres
)
;
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_TREE
,
&
tres
)
;
stralloc
sa
=
STRALLOC_ZERO
;
char
*
str
=
0
;
char
*
str
=
0
;
log_trace
(
"modify field contents of resolve tree file: "
,
treename
)
;
log_trace
(
"modify field contents of resolve tree file: "
,
treename
)
;
...
@@ -36,29 +33,32 @@ void tree_service_remove(char const *base, char const *treename, char const *ser
...
@@ -36,29 +33,32 @@ void tree_service_remove(char const *base, char const *treename, char const *ser
if
(
tres
.
ncontents
)
{
if
(
tres
.
ncontents
)
{
if
(
!
sastr_clean_string
(
&
sa
,
tres
.
sa
.
s
+
tres
.
contents
))
size_t
clen
=
strlen
(
tres
.
sa
.
s
+
tres
.
contents
)
;
log_dieu
(
LOG_EXIT_SYS
,
"clean string"
)
;
_init_stack_
(
stk
,
clen
+
1
)
;
if
(
!
stack_convert_string
(
&
stk
,
tres
.
sa
.
s
+
tres
.
contents
,
clen
))
log_dieusys
(
LOG_EXIT_SYS
,
"convert string to stack"
)
;
if
(
!
s
astr
_remove_element
(
&
s
a
,
service
))
if
(
!
s
tack
_remove_element
_g
(
&
s
tk
,
service
))
log_dieu
(
LOG_EXIT_SYS
,
"remove service: "
,
service
,
" from selection"
)
;
log_dieu
(
LOG_EXIT_SYS
,
"remove service: "
,
service
,
" from selection"
)
;
if
(
sa
.
len
)
{
if
(
stk
.
len
)
{
if
(
!
sastr_rebuild_in_oneline
(
&
sa
))
log_dieu
(
LOG_EXIT_SYS
,
"rebuild stralloc list"
)
;
if
(
!
stack_convert_tostring
(
&
stk
))
str
=
sa
.
s
;
log_dieu
(
LOG_EXIT_SYS
,
"convert stack to string"
)
;
str
=
stk
.
s
;
}
else
str
=
""
;
}
else
str
=
""
;
if
(
!
resolve_modify_field
(
wres
,
E_RESOLVE_TREE_CONTENTS
,
str
))
if
(
!
resolve_modify_field
(
wres
,
E_RESOLVE_TREE_CONTENTS
,
str
))
log_dieusys
(
LOG_EXIT_SYS
,
"modify resolve file of: "
,
treename
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"modify resolve file of: "
,
treename
)
;
}
if
(
tres
.
ncontents
)
tres
.
ncontents
--
;
tres
.
ncontents
--
;
if
(
!
resolve_write_g
(
wres
,
base
,
treename
))
if
(
!
resolve_write_g
(
wres
,
base
,
treename
))
log_dieusys
(
LOG_EXIT_SYS
,
"write resolve file of tree: "
,
treename
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write resolve file of tree: "
,
treename
)
;
}
stralloc_free
(
&
sa
)
;
resolve_free
(
wres
)
;
resolve_free
(
wres
)
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment