Apply clang-format for core/shared and product-mini files (#785)
Apply clang-format for core/shared and product-mini files
This commit is contained in:
@ -9,9 +9,10 @@
|
||||
|
||||
#include "ems/ems_gc.h"
|
||||
|
||||
mem_allocator_t mem_allocator_create(void *mem, uint32_t size)
|
||||
mem_allocator_t
|
||||
mem_allocator_create(void *mem, uint32_t size)
|
||||
{
|
||||
return gc_init_with_pool((char *) mem, size);
|
||||
return gc_init_with_pool((char *)mem, size);
|
||||
}
|
||||
|
||||
mem_allocator_t
|
||||
@ -20,15 +21,14 @@ mem_allocator_create_with_struct_and_pool(void *struct_buf,
|
||||
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);
|
||||
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)
|
||||
void
|
||||
mem_allocator_destroy(mem_allocator_t allocator)
|
||||
{
|
||||
gc_destroy_with_pool((gc_handle_t) allocator);
|
||||
gc_destroy_with_pool((gc_handle_t)allocator);
|
||||
}
|
||||
|
||||
uint32
|
||||
@ -40,33 +40,33 @@ mem_allocator_get_heap_struct_size()
|
||||
void *
|
||||
mem_allocator_malloc(mem_allocator_t allocator, uint32_t size)
|
||||
{
|
||||
return gc_alloc_vo((gc_handle_t) allocator, size);
|
||||
return gc_alloc_vo((gc_handle_t)allocator, size);
|
||||
}
|
||||
|
||||
void *
|
||||
mem_allocator_realloc(mem_allocator_t allocator, void *ptr, uint32_t size)
|
||||
{
|
||||
return gc_realloc_vo((gc_handle_t) allocator, ptr, size);
|
||||
return gc_realloc_vo((gc_handle_t)allocator, ptr, size);
|
||||
}
|
||||
|
||||
void mem_allocator_free(mem_allocator_t allocator, void *ptr)
|
||||
void
|
||||
mem_allocator_free(mem_allocator_t allocator, void *ptr)
|
||||
{
|
||||
if (ptr)
|
||||
gc_free_vo((gc_handle_t) allocator, ptr);
|
||||
gc_free_vo((gc_handle_t)allocator, ptr);
|
||||
}
|
||||
|
||||
int
|
||||
mem_allocator_migrate(mem_allocator_t allocator,
|
||||
char *pool_buf_new, uint32 pool_buf_size)
|
||||
mem_allocator_migrate(mem_allocator_t allocator, char *pool_buf_new,
|
||||
uint32 pool_buf_size)
|
||||
{
|
||||
return gc_migrate((gc_handle_t) allocator,
|
||||
pool_buf_new, pool_buf_size);
|
||||
return gc_migrate((gc_handle_t)allocator, pool_buf_new, pool_buf_size);
|
||||
}
|
||||
|
||||
bool
|
||||
mem_allocator_is_heap_corrupted(mem_allocator_t allocator)
|
||||
{
|
||||
return gc_is_heap_corrupted((gc_handle_t) allocator);
|
||||
return gc_is_heap_corrupted((gc_handle_t)allocator);
|
||||
}
|
||||
|
||||
#else /* else of DEFAULT_MEM_ALLOCATOR */
|
||||
@ -76,23 +76,23 @@ mem_allocator_is_heap_corrupted(mem_allocator_t allocator)
|
||||
typedef struct mem_allocator_tlsf {
|
||||
tlsf_t tlsf;
|
||||
korp_mutex lock;
|
||||
}mem_allocator_tlsf;
|
||||
} mem_allocator_tlsf;
|
||||
|
||||
mem_allocator_t
|
||||
mem_allocator_create(void *mem, uint32_t size)
|
||||
{
|
||||
mem_allocator_tlsf *allocator_tlsf;
|
||||
tlsf_t tlsf;
|
||||
char *mem_aligned = (char*)(((uintptr_t)mem + 3) & ~3);
|
||||
char *mem_aligned = (char *)(((uintptr_t)mem + 3) & ~3);
|
||||
|
||||
if (size < 1024) {
|
||||
printf("Create mem allocator failed: pool size must be "
|
||||
"at least 1024 bytes.\n");
|
||||
"at least 1024 bytes.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size -= mem_aligned - (char*)mem;
|
||||
mem = (void*)mem_aligned;
|
||||
size -= mem_aligned - (char *)mem;
|
||||
mem = (void *)mem_aligned;
|
||||
|
||||
tlsf = tlsf_create_with_pool(mem, size);
|
||||
if (!tlsf) {
|
||||
@ -174,12 +174,10 @@ mem_allocator_free(mem_allocator_t allocator, void *ptr)
|
||||
}
|
||||
|
||||
int
|
||||
mem_allocator_migrate(mem_allocator_t allocator,
|
||||
mem_allocator_t allocator_old)
|
||||
mem_allocator_migrate(mem_allocator_t allocator, mem_allocator_t allocator_old)
|
||||
{
|
||||
return tlsf_migrate((mem_allocator_tlsf *) allocator,
|
||||
(mem_allocator_tlsf *) allocator_old);
|
||||
return tlsf_migrate((mem_allocator_tlsf *)allocator,
|
||||
(mem_allocator_tlsf *)allocator_old);
|
||||
}
|
||||
|
||||
#endif /* end of DEFAULT_MEM_ALLOCATOR */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user