Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
d552db42
Commit
d552db42
authored
Jan 23, 2014
by
Damien George
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #214 from pfalcon/compile-mem-leaks
Memory leaks in lexer/compiler
parents
3257d354
fd313585
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
2 deletions
+15
-2
py/compile.c
py/compile.c
+8
-2
py/lexer.c
py/lexer.c
+1
-0
py/scope.c
py/scope.c
+5
-0
py/scope.h
py/scope.h
+1
-0
No files found.
py/compile.c
View file @
d552db42
...
...
@@ -3156,6 +3156,12 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, bool is_repl) {
bool
had_error
=
comp
->
had_error
;
m_del_obj
(
compiler_t
,
comp
);
uint
unique_code_id
=
module_scope
->
unique_code_id
;
for
(
scope_t
*
s
=
module_scope
;
s
;)
{
scope_t
*
next
=
s
->
next
;
scope_free
(
s
);
s
=
next
;
}
if
(
had_error
)
{
// TODO return a proper error message
...
...
@@ -3163,11 +3169,11 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, bool is_repl) {
}
else
{
#if MICROPY_EMIT_CPYTHON
// can't create code, so just return true
(
void
)
module_scope
;
// to suppress warning that module_scope is unused
(
void
)
unique_code_id
;
// to suppress warning that module_scope is unused
return
mp_const_true
;
#else
// return function that executes the outer module
return
rt_make_function_from_id
(
module_scope
->
unique_code_id
);
return
rt_make_function_from_id
(
unique_code_id
);
#endif
}
}
py/lexer.c
View file @
d552db42
...
...
@@ -691,6 +691,7 @@ void mp_lexer_free(mp_lexer_t *lex) {
lex
->
stream_close
(
lex
->
stream_data
);
}
vstr_clear
(
&
lex
->
vstr
);
m_del
(
uint16_t
,
lex
->
indent_level
,
lex
->
alloc_indent_level
);
m_del_obj
(
mp_lexer_t
,
lex
);
}
}
...
...
py/scope.c
View file @
d552db42
...
...
@@ -60,6 +60,11 @@ scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, uint
return
scope
;
}
void
scope_free
(
scope_t
*
scope
)
{
m_del
(
id_info_t
,
scope
->
id_info
,
scope
->
id_info_alloc
);
m_del
(
scope_t
,
scope
,
1
);
}
id_info_t
*
scope_find_or_add_id
(
scope_t
*
scope
,
qstr
qstr
,
bool
*
added
)
{
for
(
int
i
=
0
;
i
<
scope
->
id_info_len
;
i
++
)
{
if
(
scope
->
id_info
[
i
].
qstr
==
qstr
)
{
...
...
py/scope.h
View file @
d552db42
...
...
@@ -56,6 +56,7 @@ typedef struct _scope_t {
}
scope_t
;
scope_t
*
scope_new
(
scope_kind_t
kind
,
mp_parse_node_t
pn
,
qstr
source_file
,
uint
unique_code_id
,
uint
emit_options
);
void
scope_free
(
scope_t
*
scope
);
id_info_t
*
scope_find_or_add_id
(
scope_t
*
scope
,
qstr
qstr
,
bool
*
added
);
id_info_t
*
scope_find
(
scope_t
*
scope
,
qstr
qstr
);
id_info_t
*
scope_find_global
(
scope_t
*
scope
,
qstr
qstr
);
...
...
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