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
b62c30b4
Commit
b62c30b4
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
Generalize malloc-via-gc-heap support, make it available to unix port.
parent
8d90a382
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/malloc.c
+16
-0
16 additions, 0 deletions
py/malloc.c
stm/malloc0.c
+0
-12
0 additions, 12 deletions
stm/malloc0.c
with
16 additions
and
12 deletions
py/malloc.c
+
16
−
0
View file @
b62c30b4
...
...
@@ -19,6 +19,22 @@ static int peak_bytes_allocated = 0;
#define UPDATE_PEAK() { if (current_bytes_allocated > peak_bytes_allocated) peak_bytes_allocated = current_bytes_allocated; }
#endif
#if MICROPY_ENABLE_GC
#include
"gc.h"
// We redirect standard alloc functions to GC heap - just for the rest of
// this module. In the rest of micropython source, system malloc can be
// freely accessed - for interfacing with system and 3rd-party libs for
// example. On the other hand, some (e.g. bare-metal) ports may use GC
// heap as system heap, so, to avoid warnings, we do undef's first.
#undef malloc
#undef free
#undef realloc
#define malloc gc_alloc
#define free gc_free
#define realloc gc_realloc
#endif // MICROPY_ENABLE_GC
void
*
m_malloc
(
int
num_bytes
)
{
if
(
num_bytes
==
0
)
{
return
NULL
;
...
...
This diff is collapsed.
Click to expand it.
stm/malloc0.c
+
0
−
12
View file @
b62c30b4
...
...
@@ -29,18 +29,6 @@ void *realloc(void *ptr, size_t n) {
#endif
void
*
malloc
(
size_t
n
)
{
return
gc_alloc
(
n
);
}
void
free
(
void
*
ptr
)
{
gc_free
(
ptr
);
}
void
*
realloc
(
void
*
ptr
,
size_t
n
)
{
return
gc_realloc
(
ptr
,
n
);
}
void
__assert_func
(
void
)
{
printf
(
"
\n
ASSERT FAIL!"
);
for
(;;)
{
...
...
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