mirror of
https://github.com/HEYAHONG/HCppBox.git
synced 2025-05-09 00:21:37 +08:00
整理hevent代码
This commit is contained in:
parent
2a5d75e86d
commit
2abe81bd90
@ -8,35 +8,9 @@
|
||||
**************************************************************/
|
||||
#include "hevent.h"
|
||||
|
||||
#ifdef internal_heap_mem_alloc
|
||||
#undef internal_heap_mem_alloc
|
||||
#endif // internal_heap_mem_alloc
|
||||
#define internal_heap_mem_alloc heventloop_internal_heap_mem_alloc
|
||||
#ifdef internal_heap_mem_free
|
||||
#undef internal_heap_mem_free
|
||||
#endif // internal_heap_mem_free
|
||||
#define internal_heap_mem_free heventloop_internal_heap_mem_free
|
||||
#include "hevent/heventloop.c"
|
||||
|
||||
|
||||
#ifdef internal_heap_mem_alloc
|
||||
#undef internal_heap_mem_alloc
|
||||
#endif // internal_heap_mem_alloc
|
||||
#define internal_heap_mem_alloc heventslots_internal_heap_mem_alloc
|
||||
#ifdef internal_heap_mem_free
|
||||
#undef internal_heap_mem_free
|
||||
#endif // internal_heap_mem_free
|
||||
#define internal_heap_mem_free heventslots_internal_heap_mem_free
|
||||
#include "hevent/heventslots.c"
|
||||
|
||||
|
||||
#ifdef internal_heap_mem_alloc
|
||||
#undef internal_heap_mem_alloc
|
||||
#endif // internal_heap_mem_alloc
|
||||
#define internal_heap_mem_alloc heventchain_internal_heap_mem_alloc
|
||||
#ifdef internal_heap_mem_free
|
||||
#undef internal_heap_mem_free
|
||||
#endif // internal_heap_mem_free
|
||||
#define internal_heap_mem_free heventchain_internal_heap_mem_free
|
||||
#include "hevent/heventchain.c"
|
||||
|
||||
|
@ -48,11 +48,11 @@ size_t heventchain_with_internal_heap_min_size(void)
|
||||
return sizeof(heventchain_t)+2*sizeof(heventchain_hook_t)+64;//足够两个钩子
|
||||
}
|
||||
|
||||
static void *internal_heap_mem_alloc(size_t nbytes,void *usr)
|
||||
static void *heventchain_internal_heap_mem_alloc(size_t nbytes,void *usr)
|
||||
{
|
||||
return hmemoryheap_pool_malloc((hmemoryheap_pool_t *)usr,nbytes);
|
||||
}
|
||||
static void internal_heap_mem_free(void * ptr,void *usr)
|
||||
static void heventchain_internal_heap_mem_free(void * ptr,void *usr)
|
||||
{
|
||||
hmemoryheap_pool_free((hmemoryheap_pool_t *)usr,ptr);
|
||||
}
|
||||
@ -64,7 +64,7 @@ heventchain_t * heventchain_with_internal_heap_init(void *usr,void (*mutex_lock)
|
||||
return NULL;
|
||||
}
|
||||
hmemoryheap_pool_t *pool=hmemoryheap_pool_format(usr,mutex_lock,mutex_unlock,(uint8_t *)mem,length);
|
||||
heventchain_t *chain=heventchain_new_with_memmang_and_lock(pool,internal_heap_mem_alloc,internal_heap_mem_free,mutex_lock,mutex_unlock);
|
||||
heventchain_t *chain=heventchain_new_with_memmang_and_lock(pool,heventchain_internal_heap_mem_alloc,heventchain_internal_heap_mem_free,mutex_lock,mutex_unlock);
|
||||
if(chain!=NULL)
|
||||
{
|
||||
chain->has_internal_heap=1;
|
||||
|
@ -46,11 +46,11 @@ size_t heventloop_with_internal_heap_min_size(void)
|
||||
return sizeof(heventloop_t)+2*sizeof(heventloop_event_t)+64;//空间足够2个事件。
|
||||
}
|
||||
|
||||
static void *internal_heap_mem_alloc(size_t nbytes,void *usr)
|
||||
static void *heventloop_internal_heap_mem_alloc(size_t nbytes,void *usr)
|
||||
{
|
||||
return hmemoryheap_pool_malloc((hmemoryheap_pool_t *)usr,nbytes);
|
||||
}
|
||||
static void internal_heap_mem_free(void * ptr,void *usr)
|
||||
static void heventloop_internal_heap_mem_free(void * ptr,void *usr)
|
||||
{
|
||||
hmemoryheap_pool_free((hmemoryheap_pool_t *)usr,ptr);
|
||||
}
|
||||
@ -62,7 +62,7 @@ heventloop_t * heventloop_with_internal_heap_init(void *usr,void (*mutex_lock)(v
|
||||
return NULL;
|
||||
}
|
||||
hmemoryheap_pool_t *pool=hmemoryheap_pool_format(usr,mutex_lock,mutex_unlock,(uint8_t *)mem,length);
|
||||
heventloop_t *loop=heventloop_new_with_memmang_and_lock(pool,internal_heap_mem_alloc,internal_heap_mem_free,mutex_lock,mutex_unlock);
|
||||
heventloop_t *loop=heventloop_new_with_memmang_and_lock(pool,heventloop_internal_heap_mem_alloc,heventloop_internal_heap_mem_free,mutex_lock,mutex_unlock);
|
||||
if(loop!=NULL)
|
||||
{
|
||||
loop->has_internal_heap=1;
|
||||
|
@ -46,11 +46,11 @@ size_t heventslots_with_internal_heap_min_size(void)
|
||||
return sizeof(heventslots_t)+2*sizeof(heventslots_slot_t)+64;//空间足够2个槽。
|
||||
}
|
||||
|
||||
static void *internal_heap_mem_alloc(size_t nbytes,void *usr)
|
||||
static void *heventslots_internal_heap_mem_alloc(size_t nbytes,void *usr)
|
||||
{
|
||||
return hmemoryheap_pool_malloc((hmemoryheap_pool_t *)usr,nbytes);
|
||||
}
|
||||
static void internal_heap_mem_free(void * ptr,void *usr)
|
||||
static void heventslots_internal_heap_mem_free(void * ptr,void *usr)
|
||||
{
|
||||
hmemoryheap_pool_free((hmemoryheap_pool_t *)usr,ptr);
|
||||
}
|
||||
@ -62,7 +62,7 @@ heventslots_t * heventslots_with_internal_heap_init(void *usr,void (*mutex_lock)
|
||||
return NULL;
|
||||
}
|
||||
hmemoryheap_pool_t *pool=hmemoryheap_pool_format(usr,mutex_lock,mutex_unlock,(uint8_t *)mem,length);
|
||||
heventslots_t *slots=heventslots_new_with_memmang_and_lock(pool,internal_heap_mem_alloc,internal_heap_mem_free,mutex_lock,mutex_unlock);
|
||||
heventslots_t *slots=heventslots_new_with_memmang_and_lock(pool,heventslots_internal_heap_mem_alloc,heventslots_internal_heap_mem_free,mutex_lock,mutex_unlock);
|
||||
if(slots!=NULL)
|
||||
{
|
||||
slots->has_internal_heap=1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user