Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
f08ddef6
Commit
f08ddef6
authored
Mar 06, 2014
by
Damien George
Browse files
py: Add comments to new gc_realloc, it has some bugs.
parent
73d57935
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/gc.c
View file @
f08ddef6
...
...
@@ -345,6 +345,7 @@ void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
/* get the number of consecutive tail blocks and
the number of free blocks after last tail block */
// XXX make sure we stop if we get to end of heap
do
{
block_type
=
ATB_GET_KIND
(
block
+
n_blocks
+
n_free
);
switch
(
block_type
)
{
...
...
@@ -353,6 +354,7 @@ void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
default:
break
;
}
/* stop as soon as we find enough blocks for n_bytes */
// XXX check for n_bytes is wrong since we don't include n_free
}
while
(
block_type
!=
AT_HEAD
&&
(
n_bytes
>
(
n_blocks
*
BYTES_PER_BLOCK
)));
/* number of allocated bytes */
...
...
@@ -367,8 +369,10 @@ void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
}
/* check if we can expand in place */
}
else
if
(
n_bytes
<=
(
n_existing
+
(
n_free
*
BYTES_PER_BLOCK
)))
{
// XXX disabled for now
}
else
if
(
0
&&
n_bytes
<=
(
n_existing
+
(
n_free
*
BYTES_PER_BLOCK
)))
{
/* number of blocks needed to expand +1 if there's a remainder */
// XXX this has a bug, but don't know why; try: l=[i for i in range(1000)]; for i in l: print(i/3)
machine_uint_t
n_diff
=
(
n_bytes
-
n_existing
)
/
BYTES_PER_BLOCK
+
((
n_bytes
-
n_existing
)
%
BYTES_PER_BLOCK
!=
0
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment