int main(void) { tlsf_create_with_pool(_tlsf_heap, sizeof(_tlsf_heap)); msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); puts("Basic CCN-Lite example"); ccnl_core_init(); ccnl_start(); /* get the default interface */ gnrc_netif_t *netif = gnrc_netif_iter(NULL); /* set the relay's PID, configure the interface to interface to use CCN * nettype */ if ((netif == NULL) || (ccnl_open_netif(netif->pid, GNRC_NETTYPE_CCN) < 0)) { puts("Error registering at network interface!"); return -1; } char line_buf[SHELL_DEFAULT_BUFSIZE]; shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; }
int tlsf_add_global_pool(void *mem, size_t bytes) { if (gheap == NULL) { gheap = tlsf_create_with_pool(mem, bytes); return gheap == NULL; } else { return tlsf_add_pool(gheap, mem, bytes) == NULL; } }
void _mem_init(void* start, size_t size, int krn) { if (krn == 1){ kernel_heap = start; } //sdk_debug_logf("hk: %x", kernel_heap); /*int allocated = */tlsf_create_with_pool(start, size);//init_memory_pool(size, start); // krn_debugLogf("init mem pool: %d == %d. Heap: %x", size, allocated, kernel_heap); }
int main(void) { tlsf_create_with_pool(_tlsf_heap, sizeof(_tlsf_heap)); printf("%s started\n", APPLICATION_NAME); xtimer_init(); msg_init_queue(main_msg_queue, MAIN_MSG_QUEUE_SIZE); netdev_init(); stack_init(); exp_run(); printf("%s stopped\n", APPLICATION_NAME); return 0; }
int main(int argc, char** argv) { size_t alloc_size = 2642080; size_t size = alloc_size + tlsf_size() + tlsf_pool_overhead() + tlsf_alloc_overhead(); void* memory = ::malloc(size); tlsf_t tlsf = tlsf_create_with_pool(memory,size); tlsf_walk_pool(tlsf_get_pool(tlsf),0,0); std::cout << "try alloc " << std::hex << alloc_size << std::endl; void* ptr = tlsf_malloc(tlsf,alloc_size); assert(ptr); ::free(memory); return 0; }
Allocator::Allocator(void) { impl = new AllocatorImpl; size_t default_size = 10*1024*1024; impl->pools = (next_t*)malloc(default_size); impl->pools->next = 0x0; impl->pools->pool_size = default_size; size_t off = tlsf_size() + tlsf_pool_overhead() + sizeof(next_t); //printf("Generated Memory Pool with '%p'\n", impl->pools); impl->tlsf = tlsf_create_with_pool(((char*)impl->pools)+off, default_size-2*off); //printf("Allocator(%p)\n", impl); }
static void *l_alloc(void *ud, void *ptr, size_t osize, size_t nsize) { if (memory_pool == NULL) { const size_t mpsize = 1024 * 1024; glog_v("init_memory_pool: %dKb", mpsize / 1024); memory_pool = tlsf_create_with_pool(malloc(mpsize), mpsize); memory_pool_end = (char*)memory_pool + mpsize; } if (nsize == 0) { g_free(ptr); return NULL; } else return g_realloc(ptr, osize, nsize); }
int main(void) { #ifdef MODULE_TLSF tlsf_create_with_pool(_tlsf_heap, sizeof(_tlsf_heap)); #endif msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); printf("CCN caching started\n"); #if DOW_AUTOSTART dow_init(); thread_yield_higher(); #endif /* start the shell */ char line_buf[SHELL_DEFAULT_BUFSIZE]; shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; }
void init_kmalloc(void *mem, size_t bytes) { g_kheap = tlsf_create_with_pool(mem, bytes); }