Enlightenment CVS committal Author : cedric Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore Modified Files: ecore_strings.c Log Message: Reduce number of call to malloc (by putting the string at the end of the Ecore_String struct). =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore/ecore_strings.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- ecore_strings.c 2 Aug 2007 18:08:04 -0000 1.18 +++ ecore_strings.c 7 May 2008 13:11:34 -0000 1.19 @@ -70,15 +70,20 @@ str = ecore_hash_get(ecore_strings, string); if (!str) { + int length; /* * Allocate and initialize a new string reference. */ - str = (Ecore_String *)malloc(sizeof(Ecore_String)); + length = strlen(string) + 1; - str->string = strdup(string); + str = (Ecore_String *)malloc(sizeof(Ecore_String) + length * sizeof(char)); + + str->string = (char*)(str + 1); str->references = 0; + memcpy(str->string, string, length); + ecore_hash_set(ecore_strings, str->string, str); } @@ -110,7 +115,6 @@ if (str->references < 1) { ecore_hash_remove(ecore_strings, (char *)string); - FREE(str->string); FREE(str); } } @@ -147,6 +151,5 @@ Ecore_String *str; str = data; - FREE(str->string); FREE(str); } ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs