Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
ca21aed0
Commit
ca21aed0
authored
7 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Make m_malloc_fail() have void return type, since it doesn't return.
parent
6c9fca2a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/malloc.c
+4
-4
4 additions, 4 deletions
py/malloc.c
py/misc.h
+1
-1
1 addition, 1 deletion
py/misc.h
py/runtime.c
+1
-1
1 addition, 1 deletion
py/runtime.c
with
6 additions
and
6 deletions
py/malloc.c
+
4
−
4
View file @
ca21aed0
...
...
@@ -74,7 +74,7 @@ STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
void
*
m_malloc
(
size_t
num_bytes
)
{
void
*
ptr
=
malloc
(
num_bytes
);
if
(
ptr
==
NULL
&&
num_bytes
!=
0
)
{
return
m_malloc_fail
(
num_bytes
);
m_malloc_fail
(
num_bytes
);
}
#if MICROPY_MEM_STATS
MP_STATE_MEM
(
total_bytes_allocated
)
+=
num_bytes
;
...
...
@@ -100,7 +100,7 @@ void *m_malloc_maybe(size_t num_bytes) {
void
*
m_malloc_with_finaliser
(
size_t
num_bytes
)
{
void
*
ptr
=
malloc_with_finaliser
(
num_bytes
);
if
(
ptr
==
NULL
&&
num_bytes
!=
0
)
{
return
m_malloc_fail
(
num_bytes
);
m_malloc_fail
(
num_bytes
);
}
#if MICROPY_MEM_STATS
MP_STATE_MEM
(
total_bytes_allocated
)
+=
num_bytes
;
...
...
@@ -115,7 +115,7 @@ void *m_malloc_with_finaliser(size_t num_bytes) {
void
*
m_malloc0
(
size_t
num_bytes
)
{
void
*
ptr
=
m_malloc
(
num_bytes
);
if
(
ptr
==
NULL
&&
num_bytes
!=
0
)
{
return
m_malloc_fail
(
num_bytes
);
m_malloc_fail
(
num_bytes
);
}
// If this config is set then the GC clears all memory, so we don't need to.
#if !MICROPY_GC_CONSERVATIVE_CLEAR
...
...
@@ -131,7 +131,7 @@ void *m_realloc(void *ptr, size_t new_num_bytes) {
#endif
void
*
new_ptr
=
realloc
(
ptr
,
new_num_bytes
);
if
(
new_ptr
==
NULL
&&
new_num_bytes
!=
0
)
{
return
m_malloc_fail
(
new_num_bytes
);
m_malloc_fail
(
new_num_bytes
);
}
#if MICROPY_MEM_STATS
// At first thought, "Total bytes allocated" should only grow,
...
...
This diff is collapsed.
Click to expand it.
py/misc.h
+
1
−
1
View file @
ca21aed0
...
...
@@ -92,7 +92,7 @@ void *m_realloc(void *ptr, size_t new_num_bytes);
void
*
m_realloc_maybe
(
void
*
ptr
,
size_t
new_num_bytes
,
bool
allow_move
);
void
m_free
(
void
*
ptr
);
#endif
NORETURN
void
*
m_malloc_fail
(
size_t
num_bytes
);
NORETURN
void
m_malloc_fail
(
size_t
num_bytes
);
#if MICROPY_MEM_STATS
size_t
m_get_total_bytes_allocated
(
void
);
...
...
This diff is collapsed.
Click to expand it.
py/runtime.c
+
1
−
1
View file @
ca21aed0
...
...
@@ -1408,7 +1408,7 @@ mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_i
#endif // MICROPY_ENABLE_COMPILER
NORETURN
void
*
m_malloc_fail
(
size_t
num_bytes
)
{
NORETURN
void
m_malloc_fail
(
size_t
num_bytes
)
{
DEBUG_printf
(
"memory allocation failed, allocating %u bytes
\n
"
,
(
uint
)
num_bytes
);
#if MICROPY_ENABLE_GC
if
(
gc_is_locked
())
{
...
...
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