1 /* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
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.
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.
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/>.
19 #ifndef EINA_INLINE_TRASH_X__
20 #define EINA_INLINE_TRASH_X__
23 * @brief Initialize a trash before using it.
25 * @param trash The trash.
27 * This function just set to zero the trash to correctly
30 * @note You can just set *trash to @c NULL and you will have
34 eina_trash_init(Eina_Trash **trash)
40 * @brief Push an unused pointer in the trash instead of freeing it.
42 * @param trash A pointer to an Eina_Trash.
43 * @param data An unused pointer big enougth to put a (void*).
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.
49 * @note Do never use the pointer after insertion or bad things will
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.
56 eina_trash_push(Eina_Trash **trash, void *data)
60 tmp = (Eina_Trash *)data;
66 * @brief Pop an available pointer from the trash if possible.
68 * @param trash A pointer to an Eina_Trash.
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.
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.
78 eina_trash_pop(Eina_Trash **trash)
85 *trash = (*trash)->next;