forked from enlightenment/efl
Another eina_inarray example.
Patch by: "Daniel Vieira Franzolin" <daniel@profusion.mobi> SVN revision: 68835
This commit is contained in:
parent
4a091a072c
commit
9816cfd263
|
@ -0,0 +1,33 @@
|
|||
//Compile with:
|
||||
//gcc -g eina_inarray_02.c -o eina_inarray_02 `pkg-config --cflags --libs eina`
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const char* strings[] = {
|
||||
"helo", "hera", "starbuck", "kat", "boomer",
|
||||
"hotdog", "longshot", "jammer", "crashdown", "hardball",
|
||||
"duck", "racetrack", "apolo", "husker", "freaker",
|
||||
"skulls", "bulldog", "flat top", "hammerhead", "gonzo"
|
||||
};
|
||||
char **str, **str2;
|
||||
Eina_Inarray *iarr;
|
||||
int i;
|
||||
|
||||
eina_init();
|
||||
iarr = eina_inarray_new(sizeof(char *), 0);
|
||||
|
||||
for (i = 0; i < 20; i++){
|
||||
str = &strings[i];
|
||||
eina_inarray_append(iarr, str);
|
||||
}
|
||||
|
||||
printf("Inline array of strings:\n");
|
||||
EINA_INARRAY_FOREACH(iarr, str2)
|
||||
printf("string: %s(pointer: %p)\n", *str2, str2);
|
||||
|
||||
eina_inarray_free(iarr);
|
||||
eina_shutdown();
|
||||
}
|
|
@ -118,6 +118,36 @@
|
|||
* @example eina_inarray_01.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @page eina_inarray_example_02 Eina inline array of strings
|
||||
* @dontinclude eina_inarray_02.c
|
||||
*
|
||||
* This example will create an inline array of strings, add some elements and
|
||||
* then print them. This example is based on @ref eina_array_01_example_page and
|
||||
* @ref eina_inarray_example_01.
|
||||
*
|
||||
* We start with some variable declarations and eina initialization:
|
||||
* @skip int
|
||||
* @until eina_init
|
||||
*
|
||||
* We then create the array much like we did on @ref eina_inarray_example_01:
|
||||
* @until inarray_new
|
||||
*
|
||||
* The point were this example significantly differs from the first eina inline
|
||||
* array example. We'll not be adding the strings themselves to the array since
|
||||
* their size varies, we'll store pointer to the strings instead. We therefore
|
||||
* use @c char** to populate our inline array:
|
||||
* @until }
|
||||
*
|
||||
* The source for this example: @ref eina_inarray_02_c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @page eina_inarray_02_c eina_inarray_02.c
|
||||
* @include eina_inarray_02.c
|
||||
* @example eina_inarray_02.c
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Eina_Data_Types_Group Data Types
|
||||
*
|
||||
|
@ -144,8 +174,9 @@
|
|||
* of the array is a lot more costly than appending, so those operations should
|
||||
* be minimized.
|
||||
*
|
||||
* Example:
|
||||
* @ref eina_inarray_example_01
|
||||
* Examples:
|
||||
* @li @ref eina_inarray_example_01
|
||||
* @li @ref eina_inarray_example_02
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue