diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/eet/src/lib/eet_alloc.c | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/libraries/eet/src/lib/eet_alloc.c b/libraries/eet/src/lib/eet_alloc.c deleted file mode 100644 index 29e276c..0000000 --- a/libraries/eet/src/lib/eet_alloc.c +++ /dev/null | |||
@@ -1,93 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <Eina.h> | ||
6 | |||
7 | #include "Eet.h" | ||
8 | #include "Eet_private.h" | ||
9 | |||
10 | typedef struct _Eet_Mempool Eet_Mempool; | ||
11 | struct _Eet_Mempool | ||
12 | { | ||
13 | const char *name; | ||
14 | Eina_Mempool *mp; | ||
15 | size_t size; | ||
16 | }; | ||
17 | |||
18 | #define GENERIC_ALLOC_FREE(TYPE, Type) \ | ||
19 | Eet_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \ | ||
20 | \ | ||
21 | TYPE * \ | ||
22 | Type##_malloc(unsigned int num) \ | ||
23 | { \ | ||
24 | return eina_mempool_malloc(Type##_mp.mp, num * sizeof (TYPE)); \ | ||
25 | } \ | ||
26 | TYPE * \ | ||
27 | Type##_calloc(unsigned int num) \ | ||
28 | { \ | ||
29 | return eina_mempool_calloc(Type##_mp.mp, num * sizeof (TYPE)); \ | ||
30 | } \ | ||
31 | void \ | ||
32 | Type##_mp_free(TYPE *e) \ | ||
33 | { \ | ||
34 | eina_mempool_free(Type##_mp.mp, e); \ | ||
35 | } | ||
36 | |||
37 | GENERIC_ALLOC_FREE(Eet_File_Directory, eet_file_directory); | ||
38 | GENERIC_ALLOC_FREE(Eet_File_Node, eet_file_node); | ||
39 | GENERIC_ALLOC_FREE(Eet_File_Header, eet_file_header); | ||
40 | GENERIC_ALLOC_FREE(Eet_Dictionary, eet_dictionary); | ||
41 | GENERIC_ALLOC_FREE(Eet_File, eet_file); | ||
42 | |||
43 | static Eet_Mempool *mempool_array[] = { | ||
44 | &eet_file_directory_mp, | ||
45 | &eet_file_node_mp, | ||
46 | &eet_file_header_mp, | ||
47 | &eet_dictionary_mp, | ||
48 | &eet_file_mp, | ||
49 | }; | ||
50 | |||
51 | Eina_Bool | ||
52 | eet_mempool_init(void) | ||
53 | { | ||
54 | const char *choice; | ||
55 | unsigned int i; | ||
56 | |||
57 | choice = getenv("EINA_MEMPOOL"); | ||
58 | if ((!choice) || (!choice[0])) | ||
59 | choice = "chained_mempool"; | ||
60 | |||
61 | for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i) | ||
62 | { | ||
63 | retry: | ||
64 | mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 64); | ||
65 | if (!mempool_array[i]->mp) | ||
66 | { | ||
67 | if (!strcmp(choice, "pass_through")) | ||
68 | { | ||
69 | ERR("Falling back to pass through ! Previously tried '%s' mempool.", choice); | ||
70 | choice = "pass_through"; | ||
71 | goto retry; | ||
72 | } | ||
73 | else | ||
74 | { | ||
75 | ERR("Impossible to allocate mempool '%s' !", choice); | ||
76 | return EINA_FALSE; | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | return EINA_TRUE; | ||
81 | } | ||
82 | |||
83 | void | ||
84 | eet_mempool_shutdown(void) | ||
85 | { | ||
86 | unsigned int i; | ||
87 | |||
88 | for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i) | ||
89 | { | ||
90 | eina_mempool_del(mempool_array[i]->mp); | ||
91 | mempool_array[i]->mp = NULL; | ||
92 | } | ||
93 | } | ||