mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Use nlr_raise in xalloc
This commit is contained in:
parent
765632af91
commit
c5fb6657fd
@ -20,8 +20,7 @@ void *xalloc(uint32_t size)
|
|||||||
{
|
{
|
||||||
void *mem = gc_alloc(size, false);
|
void *mem = gc_alloc(size, false);
|
||||||
if (mem == NULL) {
|
if (mem == NULL) {
|
||||||
mp_obj_exception_clear_traceback(oom_interrupt);
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Out of Memory!!"));
|
||||||
pendsv_nlr_jump(oom_interrupt);
|
|
||||||
}
|
}
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
@ -30,8 +29,7 @@ void *xalloc0(uint32_t size)
|
|||||||
{
|
{
|
||||||
void *mem = gc_alloc(size, false);
|
void *mem = gc_alloc(size, false);
|
||||||
if (mem == NULL) {
|
if (mem == NULL) {
|
||||||
mp_obj_exception_clear_traceback(oom_interrupt);
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Out of Memory!!"));
|
||||||
pendsv_nlr_jump(oom_interrupt);
|
|
||||||
}
|
}
|
||||||
memset(mem, 0, size);
|
memset(mem, 0, size);
|
||||||
return mem;
|
return mem;
|
||||||
@ -46,8 +44,7 @@ void *xrealloc(void *ptr, uint32_t size)
|
|||||||
{
|
{
|
||||||
ptr = gc_realloc(ptr, size);
|
ptr = gc_realloc(ptr, size);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
mp_obj_exception_clear_traceback(oom_interrupt);
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Out of Memory!!"));
|
||||||
pendsv_nlr_jump(oom_interrupt);
|
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user