diff options
Diffstat (limited to 'libraries/eina/src/include/eina_inline_trash.x')
-rw-r--r-- | libraries/eina/src/include/eina_inline_trash.x | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/libraries/eina/src/include/eina_inline_trash.x b/libraries/eina/src/include/eina_inline_trash.x deleted file mode 100644 index 4a50611..0000000 --- a/libraries/eina/src/include/eina_inline_trash.x +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2008 Cedric Bail | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This library is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library; | ||
16 | * if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef EINA_INLINE_TRASH_X__ | ||
20 | #define EINA_INLINE_TRASH_X__ | ||
21 | |||
22 | /** | ||
23 | * @brief Initialize a trash before using it. | ||
24 | * | ||
25 | * @param trash The trash. | ||
26 | * | ||
27 | * This function just set to zero the trash to correctly | ||
28 | * initialize it. | ||
29 | * | ||
30 | * @note You can just set *trash to NULL and you will have | ||
31 | * the same result. | ||
32 | */ | ||
33 | static inline void | ||
34 | eina_trash_init(Eina_Trash **trash) | ||
35 | { | ||
36 | *trash = NULL; | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * @brief Push an unused pointer in the trash instead of freeing it. | ||
41 | * | ||
42 | * @param trash A pointer to an Eina_Trash. | ||
43 | * @param data An unused pointer big enougth to put a (void*). | ||
44 | * | ||
45 | * Instead of freeing a pointer and put pressure on malloc/free | ||
46 | * you can push it in a trash for a later use. This function just | ||
47 | * provide a fast way to push a now unused pointer into a trash. | ||
48 | * | ||
49 | * @note Do never use the pointer after insertion or bad things will | ||
50 | * happens. | ||
51 | * | ||
52 | * @note This trash will not resize, nor do anything with the size of | ||
53 | * the region pointed by @p data, so it's your duty to manage the size. | ||
54 | */ | ||
55 | static inline void | ||
56 | eina_trash_push(Eina_Trash **trash, void *data) | ||
57 | { | ||
58 | Eina_Trash *tmp; | ||
59 | |||
60 | tmp = (Eina_Trash *)data; | ||
61 | tmp->next = *trash; | ||
62 | *trash = tmp; | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * @brief Pop an available pointer from the trash if possible. | ||
67 | * | ||
68 | * @param trash A pointer to an Eina_Trash. | ||
69 | * | ||
70 | * Instead of calling malloc, and putting pressure on malloc/free | ||
71 | * you can recycle the content of the trash, if it's not empty. | ||
72 | * | ||
73 | * @note This trash will not resize, nor do anything with the size of | ||
74 | * the region pointed by pointer inside the trash, so it's your duty | ||
75 | * to manage the size of the returned pointer. | ||
76 | */ | ||
77 | static inline void* | ||
78 | eina_trash_pop(Eina_Trash **trash) | ||
79 | { | ||
80 | void *tmp; | ||
81 | |||
82 | tmp = *trash; | ||
83 | |||
84 | if (*trash) | ||
85 | *trash = (*trash)->next; | ||
86 | |||
87 | return tmp; | ||
88 | } | ||
89 | |||
90 | #endif | ||