1 /* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
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_TRASH_H__
20 #define EINA_TRASH_H__
23 * @addtogroup Eina_Data_Types_Group Data Types
29 * @addtogroup Eina_Containers_Group Containers
35 * @defgroup Eina_Trash_Group Trash
42 * Type for a generic container of unused allocated pointer.
44 typedef struct _Eina_Trash Eina_Trash;
48 * Type for a generic container of unused allocated pointer.
52 Eina_Trash *next; /**< next item in trash. */
55 static inline void eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1);
56 static inline void eina_trash_push(Eina_Trash **trash, void *data) EINA_ARG_NONNULL(1);
57 static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
60 * @def EINA_TRASH_CLEAN
61 * @brief Macro to remove all pointer from the trash.
63 * @param trash The trash to clean.
64 * @param data The pointer extracted from the trash.
66 * This macro allow the cleaning of @p trash in an easy way. It will
67 * remove all pointers from @p trash until it's empty.
69 * This macro can be used for freeing the data in the trash, like in
70 * the following example:
73 * Eina_Trash *trash = NULL;
76 * // trash is filled with pointer to some duped strings.
78 * EINA_TRASH_CLEAN(&trash, data)
82 * @note this macro is useful when you implement some memory pool.
84 #define EINA_TRASH_CLEAN(trash, data) while ((data = eina_trash_pop(trash)))
86 #include "eina_inline_trash.x"
100 #endif /* EINA_TRASH_H_ */