summaryrefslogtreecommitdiff
path: root/py/obj.h
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-04-28 00:16:57 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-04-28 00:33:21 +0300
commita224067846ad92c09249abdcb77fac7420eb1a95 (patch)
tree94c41d38fc7ce9a5f2b6b51ae5ac3c76ab269cde /py/obj.h
parent7ce6a8fe46e5424fa615f33e1952aad6173fcbe5 (diff)
py: Clear allocated, but unused memory in containers.
Also, clear up freed slots in containers. As a follow up to 32bef315be8e56ad2d7f69223fe7b9606893b6ab.
Diffstat (limited to 'py/obj.h')
-rw-r--r--py/obj.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/py/obj.h b/py/obj.h
index 5bf5352a1..35c98d371 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -539,3 +539,5 @@ bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, u
bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *items2, uint len2);
mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp_obj_t *args);
mp_obj_t mp_seq_count_obj(const mp_obj_t *items, uint len, mp_obj_t value);
+// Helper to clear stale pointers from allocated, but unused memory, to preclude GC problems
+#define mp_seq_clear(start, len, alloc_len, item_sz) memset((byte*)(start) + (len) * (item_sz), 0, ((alloc_len) - (len)) * (item_sz))