Eina inline array of strings

This example creates an inline array of strings, adds some elements, and then prints 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 EINA_UNUSED, char **argv EINA_UNUSED)
{
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;

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

iarr = eina_inarray_new(sizeof(char *), 0);

The point is this example significantly differs from the first eina inline array example. We are not going to add the strings themselves to the array since their size varies, we are going to store a pointer to the strings instead. We therefore use char** to populate our inline array:

for (i = 0; i < 20; i++){
str = (char **)(&strings[i]);
eina_inarray_push(iarr, str);
}

The source for this example: eina_inarray_02.c

EINA_UNUSED
#define EINA_UNUSED
Definition: eina_types.h:339
eina_init
EAPI int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:279
eina_inarray_push
int eina_inarray_push(Eina_Inarray *array, const void *data)
Copies the data as the last member of the array.
Definition: eina_inarray.c:411
eina_inarray_new
Eina_Inarray * eina_inarray_new(unsigned int member_size, unsigned int step)
Creates a new inline array.
Definition: eina_inarray.c:342
_Eina_Inarray
Inline array structure.
Definition: eina_inarray.h:225