Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
43f1c808
Commit
43f1c808
authored
Jan 01, 2014
by
Paul Sokolovsky
Browse files
m_realloc: Account only allocation size difference in total_bytes_allocated.
parent
4b57fac1
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/malloc.c
View file @
43f1c808
...
...
@@ -41,7 +41,12 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) {
printf
(
"could not allocate memory, reallocating %d bytes
\n
"
,
new_num_bytes
);
return
NULL
;
}
total_bytes_allocated
+=
new_num_bytes
;
// At first thought, "Total bytes allocated" should only grow,
// after all, it's *total*. But consider for example 2K block
// shrunk to 1K and then grown to 2K again. It's still 2K
// allocated total. If we process only positive increments,
// we'll count 3K.
total_bytes_allocated
+=
new_num_bytes
-
old_num_bytes
;
return
ptr
;
}
...
...
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