Ecore_String_Group (3) - Linux Manuals

Ecore_String_Group: These functions allow you to store one copy of a string, and use it throughout your program.

NAME

String Instance Functions - These functions allow you to store one copy of a string, and use it throughout your program.

Functions


EAPI const char * ecore_string_instance (const char *string)
Retrieves an instance of a string for use in an ecore program.
EAPI void ecore_string_release (const char *string)
Notes that the given string has lost an instance.

Detailed Description

These functions allow you to store one copy of a string, and use it throughout your program.

This is a method to reduce the number of duplicated strings kept in memory. It's pretty common for the same strings to be dynamically allocated repeatedly between applications and libraries, especially in circumstances where you could have multiple copies of a structure that allocates the string. So rather than duplicating and freeing these strings, you request a read-only pointer to an existing string and only incur the overhead of a hash lookup.

It sounds like micro-optimizing, but profiling has shown this can have a significant impact as you scale the number of copies up. It improves string creation/destruction speed, reduces memory use and decreases memory fragmentation, so a win all-around.

Function Documentation

EAPI const char* ecore_string_instance (const char * string)

Retrieves an instance of a string for use in an ecore program.

Parameters:

string The string to retrieve an instance of.

Returns:

A pointer to an instance of the string on success. NULL on failure.

References ecore_hash_get(), and ecore_hash_set().

EAPI void ecore_string_release (const char * string)

Notes that the given string has lost an instance.

It will free the string if no other instances are left.

Parameters:

string The given string.

References ecore_hash_get(), and ecore_hash_remove().

Author

Generated automatically by Doxygen for Ecore from the source code.