Add more checks to enhance app heap's security (#428)

This commit is contained in:
Wenyong Huang
2020-10-22 18:52:33 +08:00
committed by GitHub
parent c515fb1b75
commit 91b9458ebd
10 changed files with 431 additions and 205 deletions

View File

@ -14,11 +14,29 @@ mem_allocator_t mem_allocator_create(void *mem, uint32_t size)
return gc_init_with_pool((char *) mem, size);
}
mem_allocator_t
mem_allocator_create_with_struct_and_pool(void *struct_buf,
uint32_t struct_buf_size,
void *pool_buf,
uint32_t pool_buf_size)
{
return gc_init_with_struct_and_pool((char *)struct_buf,
struct_buf_size,
pool_buf,
pool_buf_size);
}
void mem_allocator_destroy(mem_allocator_t allocator)
{
gc_destroy_with_pool((gc_handle_t) allocator);
}
uint32
mem_allocator_get_heap_struct_size()
{
return gc_get_heap_struct_size();
}
void *
mem_allocator_malloc(mem_allocator_t allocator, uint32_t size)
{
@ -39,16 +57,10 @@ void mem_allocator_free(mem_allocator_t allocator, void *ptr)
int
mem_allocator_migrate(mem_allocator_t allocator,
mem_allocator_t allocator_old)
char *pool_buf_new, uint32 pool_buf_size)
{
return gc_migrate((gc_handle_t) allocator,
(gc_handle_t) allocator_old);
}
int
mem_allocator_reinit_lock(mem_allocator_t allocator)
{
return gc_reinit_lock((gc_handle_t) allocator);
pool_buf_new, pool_buf_size);
}
void