Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
blaar
blibs
blc_program
Commits
2d2c32c8
Commit
2d2c32c8
authored
Dec 09, 2016
by
Arnaud Blanchard
Browse files
Avoid to destroy the memory for the argument as it is already done when the line is destroyed
parent
49d18160
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/blc_command.cpp
View file @
2d2c32c8
...
...
@@ -134,8 +134,6 @@ void blc_command_add(const char *command_name, type_blc_command_cb callback, con
APPEND_ITEM
(
&
blc_commands
,
&
blc_commands_nb
,
&
tmp_command
);
}
/* line may be allocated indefinitly, but it does not happen often. */
static
void
blc_command_interpret_block
(){
blc_mem
line
,
parameter
;
size_t
line_capability
=
0
;
...
...
@@ -166,7 +164,7 @@ static void blc_command_interpret_block(){
if
(
parameter
.
size
==
0
)
//No text after the command
{
parameter
.
data
=
NULL
;
parameter
.
chars
=
NULL
;
if
(
command
->
prompt
!=
NULL
)
//A text was expected
{
fprintf
(
stderr
,
"%s:"
,
command
->
prompt
);
...
...
@@ -174,7 +172,7 @@ static void blc_command_interpret_block(){
parameter
.
chars
[
parameter
.
size
]
=
0
;
}
if
(
command
->
callback
)
command
->
callback
(
parameter
.
chars
,
command
->
user_data
);
//In which callback is NULL ??
FREE
(
parameter
.
chars
);
parameter
.
~
blc_mem
(
);
line_capability
=
0
;
break
;
}
...
...
@@ -187,6 +185,7 @@ static void blc_command_interpret_block(){
}
}
if
(
command
<
blc_commands
)
fprintf
(
stderr
,
"Unknown command in: %s
\n
"
,
line
.
chars
);
parameter
.
chars
=
NULL
;
//Avoid to be destructed twice
}
void
blc_command_interpret
(){
...
...
Write
Preview
Supports
Markdown
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