mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add xalloc_try_alloc.
* Doesn't raise exception if there's no memory
This commit is contained in:
parent
e82e3ab785
commit
2d201357a6
@ -24,6 +24,16 @@ void *xalloc(uint32_t size)
|
||||
return mem;
|
||||
}
|
||||
|
||||
// returns null pointer without error if size==0
|
||||
void *xalloc_try_alloc(uint32_t size)
|
||||
{
|
||||
void *mem = gc_alloc(size, false);
|
||||
if (size && (mem == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
return mem;
|
||||
}
|
||||
|
||||
// returns null pointer without error if size==0
|
||||
void *xalloc0(uint32_t size)
|
||||
{
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#define __XALLOC_H__
|
||||
#include <stdint.h>
|
||||
void *xalloc(uint32_t size);
|
||||
void *xalloc_try_alloc(uint32_t size);
|
||||
void *xalloc0(uint32_t size);
|
||||
void xfree(void *mem);
|
||||
void *xrealloc(void *mem, uint32_t size);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user