py, gc: Only zero out the extra bytes at the end of the heap chunk.

This is a small optimisation to zero out only the additional bytes that
the caller did not ask for.
This commit is contained in:
Damien George
2014-04-26 22:23:42 +01:00
parent dbc81df5d4
commit 32bef315be
2 changed files with 6 additions and 10 deletions

View File

@@ -88,13 +88,9 @@ void *m_malloc_with_finaliser(int num_bytes) {
void *m_malloc0(int num_bytes) {
void *ptr = m_malloc(num_bytes);
#if MICROPY_ENABLE_GC
// the GC already zeros out all memory
#else
if (ptr != NULL) {
memset(ptr, 0, num_bytes);
}
#endif
return ptr;
}