Add LIST_INIT_VALUE & LIST_DUAL_PUSH_INIT_VALUE.
This commit is contained in:
1 parent
f8b4f44105
commit
2178dcfcab
4 files changed
+55
-2
No files matched your search
@@ -909,6 +909,19 @@ Return the oplist of the list defined by calling LIST\_DEF
|
|||||||
& LIST\_DUAL\_PUSH\_DEF with name & oplist.
|
& LIST\_DUAL\_PUSH\_DEF with name & oplist.
|
||||||
If there is no given oplist, the default oplist for standard C type is used.
|
If there is no given oplist, the default oplist for standard C type is used.
|
||||||
|
|
||||||
|
#### LIST\_INIT\_VALUE()
|
||||||
|
|
||||||
|
Define an initial value that is suitable to initialize global variable(s)
|
||||||
|
of type 'list' as created by LIST\_DEF or LIST\_DEF\_AS.
|
||||||
|
It enables to create a list as a global variable and to initialize it.
|
||||||
|
|
||||||
|
The list should still be cleared manually to avoid leaking memory.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
LIST_DEF(list_int_t, int)
|
||||||
|
list_int_t my_list = LIST_INIT_VALUE();
|
||||||
|
|
||||||
#### Created methods
|
#### Created methods
|
||||||
|
|
||||||
In the following methods, name stands for the name given to the macro that is used to identify the type.
|
In the following methods, name stands for the name given to the macro that is used to identify the type.
|
||||||
@@ -1199,6 +1212,19 @@ The methods follow closely the methods defined by LIST\_DEF.
|
|||||||
Same as LIST\_DUAL\_PUSH\_DEF except the name of the types name\_t, name\_it\_t
|
Same as LIST\_DUAL\_PUSH\_DEF except the name of the types name\_t, name\_it\_t
|
||||||
are provided.
|
are provided.
|
||||||
|
|
||||||
|
#### LIST\_DUAL\_PUSH\_INIT\_VALUE()
|
||||||
|
|
||||||
|
Define an initial value that is suitable to initialize global variable(s)
|
||||||
|
of type 'list' as created by LIST\_DUAL\_PUSH\_DEF or LIST\_DUAL\_PUSH\_DEF\_AS.
|
||||||
|
It enables to create a list as a global variable and to initialize it.
|
||||||
|
|
||||||
|
The list should still be cleared manually to avoid leaking memory.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
LIST_DUAL_PUSH_DEF(list_int_t, int)
|
||||||
|
list_int_t my_list = LIST_DUAL_PUSH_INIT_VALUE();
|
||||||
|
|
||||||
#### Created methods
|
#### Created methods
|
||||||
|
|
||||||
In the following methods, name stands for the name given to the macro that is used to identify the type.
|
In the following methods, name stands for the name given to the macro that is used to identify the type.
|
||||||
@@ -1482,7 +1508,7 @@ If there is no given oplist, the default oplist for standard C type is used.
|
|||||||
#### ARRAY\_INIT\_VALUE()
|
#### ARRAY\_INIT\_VALUE()
|
||||||
|
|
||||||
Define an initial value that is suitable to initialize global variable(s)
|
Define an initial value that is suitable to initialize global variable(s)
|
||||||
of the type associated to the (array) oplist 'oplist'.
|
of type 'array' as created by ARRAY\_DEF or ARRAY\_DEF\_AS.
|
||||||
It enables to create an array as a global variable and to initialize it.
|
It enables to create an array as a global variable and to initialize it.
|
||||||
|
|
||||||
The array should still be cleared manually to avoid leaking memory.
|
The array should still be cleared manually to avoid leaking memory.
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
/* Define an init value to init global variables of type array.
|
/* Define an init value to init global variables of type array.
|
||||||
USAGE:
|
USAGE:
|
||||||
array_t global_variable = ARRAY_INIT_VALUE(array_oplist);
|
array_t global_variable = ARRAY_INIT_VALUE();
|
||||||
*/
|
*/
|
||||||
#define ARRAY_INIT_VALUE() \
|
#define ARRAY_INIT_VALUE() \
|
||||||
{ { 0, 0, NULL } }
|
{ { 0, 0, NULL } }
|
||||||
|
|||||||
@@ -68,6 +68,21 @@
|
|||||||
((__VA_ARGS__, M_DEFAULT_OPLIST ), \
|
((__VA_ARGS__, M_DEFAULT_OPLIST ), \
|
||||||
(__VA_ARGS__ )))
|
(__VA_ARGS__ )))
|
||||||
|
|
||||||
|
/* Define an init value to init global variables of type list.
|
||||||
|
USAGE:
|
||||||
|
list_t global_variable = LIST_INIT_VALUE();
|
||||||
|
*/
|
||||||
|
#define LIST_INIT_VALUE() \
|
||||||
|
{ NULL }
|
||||||
|
|
||||||
|
|
||||||
|
/* Define an init value to init global variables of type dual push list.
|
||||||
|
USAGE:
|
||||||
|
list_t global_variable = LIST_DUAL_PUSH_INIT_VALUE();
|
||||||
|
*/
|
||||||
|
#define LIST_DUAL_PUSH_INIT_VALUE() \
|
||||||
|
{ { NULL, NULL } }
|
||||||
|
|
||||||
|
|
||||||
/********************************** INTERNAL ************************************/
|
/********************************** INTERNAL ************************************/
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ LIST_DEF_AS(list_double, ListDouble, ListDoubleIt, double)
|
|||||||
LIST_DUAL_PUSH_DEF_AS(list_doubleDP, ListDoubleDP, ListDoubleDPIt, double)
|
LIST_DUAL_PUSH_DEF_AS(list_doubleDP, ListDoubleDP, ListDoubleDPIt, double)
|
||||||
#define M_OPL_ListDoubleDP() LIST_OPLIST(list_doubleDP, M_DEFAULT_OPLIST)
|
#define M_OPL_ListDoubleDP() LIST_OPLIST(list_doubleDP, M_DEFAULT_OPLIST)
|
||||||
|
|
||||||
|
ListDouble g_array1 = LIST_INIT_VALUE();
|
||||||
|
ListDoubleDP g_array2 = LIST_DUAL_PUSH_INIT_VALUE();
|
||||||
|
|
||||||
static void test_uint(void)
|
static void test_uint(void)
|
||||||
{
|
{
|
||||||
list_uint_t v;
|
list_uint_t v;
|
||||||
@@ -674,6 +677,15 @@ static void test_double(void)
|
|||||||
ref += 1.0;
|
ref += 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert( list_double_empty_p (g_array1) );
|
||||||
|
assert( list_doubleDP_empty_p (g_array2) );
|
||||||
|
|
||||||
|
list_double_push_back(g_array1, 23.0);
|
||||||
|
list_doubleDP_push_front(g_array2, 23.0);
|
||||||
|
|
||||||
|
list_double_clear(g_array1);
|
||||||
|
list_doubleDP_clear(g_array2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_let_string(void)
|
static void test_let_string(void)
|
||||||
|
|||||||
Reference in new issue
Block a user