Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore Modified Files: Ecore_Data.h ecore_strings.c Log Message: Setup an init/shutdown system for shared strings. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/Ecore_Data.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- Ecore_Data.h 16 Nov 2005 22:17:11 -0000 1.16 +++ Ecore_Data.h 27 Nov 2005 08:00:39 -0000 1.17 @@ -419,6 +419,8 @@ int references; }; + int ecore_string_init(void); + void ecore_string_shutdown(void); char *ecore_string_instance(char *string); void ecore_string_release(char *string); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/ecore_strings.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- ecore_strings.c 5 Sep 2005 10:17:08 -0000 1.8 +++ ecore_strings.c 27 Nov 2005 08:00:39 -0000 1.9 @@ -1,7 +1,10 @@ #include "ecore_private.h" #include "Ecore_Data.h" +static void ecore_string_free_cb(void *data); + static Ecore_Hash *ecore_strings = NULL; +static int ecore_string_init_count = 0; /** * @defgroup Ecore_String_Group String Instance Functions @@ -11,6 +14,27 @@ */ /** + * Initialize the ecore string internal structure. + * @return Zero on failure, non-zero on successful initialization. + */ +int ecore_string_init() +{ + /* + * No strings have been loaded at this point, so create the hash + * table for storing string info for later. + */ + if (!ecore_string_init_count) { + ecore_strings = ecore_hash_new(ecore_str_hash, ecore_str_compare); + if (!ecore_strings) + return 0; + ecore_hash_set_free_value(ecore_strings, ecore_string_free_cb); + } + ecore_string_init_count++; + + return 1; +} + +/** * Retrieves an instance of a string for use in an ecore program. * @param string The string to retrieve an instance of. * @return A pointer to an instance of the string on success. @@ -24,13 +48,6 @@ CHECK_PARAM_POINTER_RETURN("string", string, NULL); /* - * No strings have been loaded at this point, so create the hash - * table for storing string info for later. - */ - if (!ecore_strings) - ecore_strings = ecore_hash_new(ecore_str_hash, ecore_str_compare); - - /* * Check for a previous instance of the string, if not found, create * it. */ @@ -78,3 +95,24 @@ FREE(str); } } + +/** + * Shutdown the ecore string internal structures + */ +void ecore_string_shutdown() +{ + --ecore_string_init_count; + if (!ecore_string_init_count) { + ecore_hash_destroy(ecore_strings); + ecore_strings = NULL; + } +} + +static void ecore_string_free_cb(void *data) +{ + Ecore_String *str; + + str = data; + FREE(str->string); + FREE(str); +} ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs