Eina inline array of strings

This example will create an inline array of strings, add some elements and then print them. This example is based on Basic array usage and Eina inline array usage.

We start with some variable declarations and eina initialization:

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;
struct _Eina_Inarray Eina_Inarray
Inlined array type.
Definition eina_inarray.h:191
int eina_init(void)
Initialize the Eina library.
Definition eina_main.c:244

We then create the array much like we did on Eina inline array usage :

iarr = eina_inarray_new(sizeof(char *), 0);
Eina_Inarray * eina_inarray_new(unsigned int member_size, unsigned int step)
Create new inline array.
Definition eina_inarray.c:338

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 char** to populate our inline array:

for (i = 0; i < 20; i++){
str = &strings[i];
eina_inarray_push(iarr, str);
}
int eina_inarray_push(Eina_Inarray *array, const void *data)
Copy the data as the last member of the array.
Definition eina_inarray.c:399

The source for this example: eina_inarray_02.c