6 #include "ecore_private.h"
8 #include "ecore_con_private.h"
10 typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool;
11 struct _Ecore_Con_Mempool
18 #define GENERIC_ALLOC_FREE(TYPE, Type) \
19 Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
24 return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \
28 Type##_free(TYPE *e) \
30 eina_mempool_free(Type##_mp.mp, e); \
33 GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Add, ecore_con_event_client_add);
34 GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Del, ecore_con_event_client_del);
35 GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Write, ecore_con_event_client_write);
36 GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Data, ecore_con_event_client_data);
37 GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Error, ecore_con_event_server_error);
38 GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Error, ecore_con_event_client_error);
39 GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Add, ecore_con_event_server_add);
40 GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Del, ecore_con_event_server_del);
41 GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Write, ecore_con_event_server_write);
42 GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Data, ecore_con_event_server_data);
43 GENERIC_ALLOC_FREE(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind);
45 static Ecore_Con_Mempool *mempool_array[] = {
46 &ecore_con_event_client_add_mp,
47 &ecore_con_event_client_del_mp,
48 &ecore_con_event_client_write_mp,
49 &ecore_con_event_client_data_mp,
50 &ecore_con_event_server_error_mp,
51 &ecore_con_event_client_error_mp,
52 &ecore_con_event_server_add_mp,
53 &ecore_con_event_server_del_mp,
54 &ecore_con_event_server_write_mp,
55 &ecore_con_event_server_data_mp,
56 &ecore_con_event_proxy_bind_mp
60 ecore_con_mempool_init(void)
65 choice = getenv("EINA_MEMPOOL");
66 if (!choice || !choice[0])
67 choice = "chained_mempool";
69 for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
72 mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 16);
73 if (!mempool_array[i]->mp)
75 if (strcmp(choice, "pass_through") != 0)
77 ERR("Falling back to pass through ! Previously tried '%s' mempool.", choice);
78 choice = "pass_through";
83 ERR("Impossible to allocate mempool '%s' !", choice);
91 ecore_con_mempool_shutdown(void)
95 for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
97 eina_mempool_del(mempool_array[i]->mp);
98 mempool_array[i]->mp = NULL;