eina_stringshare_example_01
//Compile with:
//gcc -g eina_stringshare_01.c -o eina_stringshare_01 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.h>
int
main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
const char *str, *str2;
const char *prologe = "The Cylons were created by man. They rebelled. They "
"evolved.";
const char *prologe2 = "%d Cylon models. %d are known. %d live in secret. "
"%d will be revealed.";
const char *prologe3 = "There are many copies. And they have a plan.";
eina_init();
str = eina_stringshare_add_length(prologe, 31);
printf("%s\n", str);
printf("length: %d\n", eina_stringshare_strlen(str));
eina_stringshare_del(str);
str = eina_stringshare_printf(prologe2, 12, 7, 4, 1);
printf("%s\n", str);
eina_stringshare_del(str);
str = eina_stringshare_nprintf(45, "%s", prologe3);
printf("%s\n", str);
str2 = eina_stringshare_add(prologe3);
printf("%s\n", str2);
eina_stringshare_ref(str2);
eina_stringshare_del(str2);
printf("%s\n", str2);
eina_stringshare_replace(&str, prologe);
printf("%s\n", str);
eina_stringshare_del(str);
eina_stringshare_del(str2);
eina_shutdown();
return 0;
}
Eina.h
Eina Utility library.
eina_shutdown
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition eina_main.c:379
eina_init
EINA_API int eina_init(void)
Initializes the Eina library.
Definition eina_main.c:291
eina_stringshare_add_length
EINA_API Eina_Stringshare * eina_stringshare_add_length(const char *str, unsigned int slen)
Retrieves an instance of a string with a specific size for use in a program.
Definition eina_stringshare.c:573
eina_stringshare_add
EINA_API Eina_Stringshare * eina_stringshare_add(const char *str)
Retrieves an instance of a string for use in a program.
Definition eina_stringshare.c:606
eina_stringshare_del
EINA_API void eina_stringshare_del(Eina_Stringshare *str)
Notes that the given string has lost an instance.
Definition eina_stringshare.c:533
eina_stringshare_strlen
EINA_API int eina_stringshare_strlen(Eina_Stringshare *str)
Notes that the given string must be shared.
Definition eina_stringshare.c:726
eina_stringshare_ref
EINA_API Eina_Stringshare * eina_stringshare_ref(Eina_Stringshare *str)
Increment references of the given shared string.
Definition eina_stringshare.c:685
eina_stringshare_replace
static Eina_Bool eina_stringshare_replace(Eina_Stringshare **p_str, const char *news)
Replace the previously stringshared pointer with new content.
Definition eina_inline_stringshare.x:78
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339