aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c')
-rw-r--r--libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c101
1 files changed, 0 insertions, 101 deletions
diff --git a/libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c b/libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c
deleted file mode 100644
index d922f20..0000000
--- a/libraries/ecore/src/lib/ecore_con/ecore_con_alloc.c
+++ /dev/null
@@ -1,101 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "Ecore.h"
6#include "ecore_private.h"
7#include "Ecore_Con.h"
8#include "ecore_con_private.h"
9
10typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool;
11struct _Ecore_Con_Mempool
12{
13 const char *name;
14 Eina_Mempool *mp;
15 size_t size;
16};
17
18#define GENERIC_ALLOC_FREE(TYPE, Type) \
19 Ecore_Con_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
20 \
21 TYPE * \
22 Type##_alloc(void) \
23 { \
24 return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE)); \
25 } \
26 \
27 void \
28 Type##_free(TYPE *e) \
29 { \
30 eina_mempool_free(Type##_mp.mp, e); \
31 }
32
33GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Add, ecore_con_event_client_add);
34GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Del, ecore_con_event_client_del);
35GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Write, ecore_con_event_client_write);
36GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Data, ecore_con_event_client_data);
37GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Error, ecore_con_event_server_error);
38GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Error, ecore_con_event_client_error);
39GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Add, ecore_con_event_server_add);
40GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Del, ecore_con_event_server_del);
41GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Write, ecore_con_event_server_write);
42GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Data, ecore_con_event_server_data);
43GENERIC_ALLOC_FREE(Ecore_Con_Event_Proxy_Bind, ecore_con_event_proxy_bind);
44
45static 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
57};
58
59void
60ecore_con_mempool_init(void)
61{
62 const char *choice;
63 unsigned int i;
64
65 choice = getenv("EINA_MEMPOOL");
66 if (!choice || !choice[0])
67 choice = "chained_mempool";
68
69 for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
70 {
71 retry:
72 mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 64);
73 if (!mempool_array[i]->mp)
74 {
75 if (strcmp(choice, "pass_through") != 0)
76 {
77 ERR("Falling back to pass through ! Previously tried '%s' mempool.", choice);
78 choice = "pass_through";
79 goto retry;
80 }
81 else
82 {
83 ERR("Impossible to allocate mempool '%s' !", choice);
84 return ;
85 }
86 }
87 }
88}
89
90void
91ecore_con_mempool_shutdown(void)
92{
93 unsigned int i;
94
95 for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
96 {
97 eina_mempool_del(mempool_array[i]->mp);
98 mempool_array[i]->mp = NULL;
99 }
100}
101