summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-03-06 23:59:01 +0000
committerDamien George <damien.p.george@gmail.com>2014-03-06 23:59:01 +0000
commitf08ddef676504dcbdc3c5b50f8dd28145dccc3f7 (patch)
tree48b4c87dbc75f79f629c77dc46f031892f0bda5a
parent73d579354be1ef7fbfb9aa316387d868504689f2 (diff)
downloadmicropython-f08ddef676504dcbdc3c5b50f8dd28145dccc3f7.tar.gz
micropython-f08ddef676504dcbdc3c5b50f8dd28145dccc3f7.zip
py: Add comments to new gc_realloc, it has some bugs.
-rw-r--r--py/gc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/py/gc.c b/py/gc.c
index 479db5b5a0..cf1bdfbc59 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -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);