EFL 1.7 svn doobies
[profile/ivi/eina.git] / src / include / eina_lalloc.h
1 /* EINA - EFL data type library
2  * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
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_LALLOC_H_
20 #define EINA_LALLOC_H_
21
22 #include "eina_types.h"
23
24 /**
25  * @addtogroup Eina_Tools_Group Tools
26  *
27  * @{
28  */
29
30 /**
31  * @defgroup Eina_Lalloc_Group Lazy allocator
32  *
33  * @{
34  */
35
36 typedef Eina_Bool (*Eina_Lalloc_Alloc)(void *user_data, int num);
37 /**
38  * @def EINA_LALLOC_ALLOC
39  * @param function The function to allocate.
40  */
41 #define EINA_LALLOC_ALLOC(function) ((Eina_Lalloc_Alloc)function)
42 typedef void      (*Eina_Lalloc_Free)(void *user_data);
43 /**
44  * @def EINA_LALLOC_FREE
45  * @param function The function to free.
46  */
47 #define EINA_LALLOC_FREE(function)  ((Eina_Lalloc_Free)function)
48
49 typedef struct _Eina_Lalloc Eina_Lalloc;
50
51 EAPI Eina_Lalloc *eina_lalloc_new(void             *data,
52                                   Eina_Lalloc_Alloc alloc_cb,
53                                   Eina_Lalloc_Free  free_cb,
54                                   int               num_init) EINA_ARG_NONNULL(2, 3);
55 EAPI void      eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
56 EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a,
57                                         int          num) EINA_ARG_NONNULL(1);
58 EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
59
60 /**
61  * @}
62  */
63
64 /**
65  * @}
66  */
67
68 #endif /* EINA_LALLOC_H_ */