py: Add m_malloc_fail function to handle memory allocation error.

A malloc/realloc fail now throws MemoryError.
This commit is contained in:
Damien George
2014-04-04 10:52:59 +00:00
parent 072cf022e0
commit 6902eeda25
7 changed files with 20 additions and 6 deletions

View File

@@ -17,6 +17,9 @@ typedef struct _mp_obj_exception_t {
mp_obj_tuple_t args;
} mp_obj_exception_t;
// Instance of MemoryError exception - needed by mp_malloc_fail
const mp_obj_exception_t mp_const_MemoryError_obj = {{&mp_type_MemoryError}, MP_OBJ_NULL, {{&mp_type_tuple}, 0}};
// Instance of GeneratorExit exception - needed by generator.close()
// This would belong to objgenerator.c, but to keep mp_obj_exception_t
// definition module-private so far, have it here.