Hello, this is not correct. It returns a different pointer on each call. The content behind the pointer is the same, correct. The pointer is NOT.
Your example is missing one thing, you are not using the value, think of a case where you give the returned value to a function that calls free. The compiler might be unable to detect that and assume that it can move out the function call, which causes a multi-free call on the same pointer. Greetings bu5hm4n Am 24. Mai 2018 15:58:01 MESZ schrieb Gustavo Sverzut Barbieri <[email protected]>: >I disagree with that signature. > >it does a malloc to populate a cache, which is later used... then *all >calls returns the same, given the same parameters* (pure). > >the cache is only cleared on eina shutdown, which is unlikely to >affect use cases (would break "while (1) { eina_init(); >eina_module_symbol_path_get(sym, dir); eina_shutdown();}" as it would >move the symbol path get out of the loop. > > > >On Thu, May 24, 2018 at 1:39 AM, Cedric BAIL <[email protected]> >wrote: >> cedric pushed a commit to branch master. >> >> >http://git.enlightenment.org/core/efl.git/commit/?id=9dce56687b5967a36514c8f731a146197415f481 >> >> commit 9dce56687b5967a36514c8f731a146197415f481 >> Author: Cedric BAIL <[email protected]> >> Date: Wed May 23 19:36:56 2018 -0700 >> >> eina: path get actually allocate memory and can't be pure. >> --- >> src/lib/eina/eina_module.h | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/src/lib/eina/eina_module.h b/src/lib/eina/eina_module.h >> index dafdb203ec..151b1c3101 100644 >> --- a/src/lib/eina/eina_module.h >> +++ b/src/lib/eina/eina_module.h >> @@ -230,7 +230,7 @@ EAPI void >eina_module_symbol_global_set(Eina_Module *module, Eina_Bool global) E >> * or allocation fails, this function returns @c NULL. >> */ >> EAPI char * >> - eina_module_symbol_path_get(const void *symbol, const char >*sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2); >> + eina_module_symbol_path_get(const void *symbol, const char >*sub_dir) EINA_MALLOC EINA_ARG_NONNULL(1, 2); >> >> /** >> * @brief Returns the path built from the value of an environment >variable and a >> @@ -247,7 +247,7 @@ EAPI char * >> * allocation fails, this function returns @c NULL. >> */ >> EAPI char * >> - eina_module_environment_path_get(const char *env, const char >*sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2); >> + eina_module_environment_path_get(const char *env, const char >*sub_dir) EINA_MALLOC EINA_ARG_NONNULL(1, 2); >> >> >> /** >> >> -- >> >> > > > >-- >Gustavo Sverzut Barbieri >-------------------------------------- >Mobile: +55 (16) 99354-9890 > >------------------------------------------------------------------------------ >Check out the vibrant tech community on one of the world's most >engaging tech sites, Slashdot.org! http://sdm.link/slashdot >_______________________________________________ >enlightenment-devel mailing list >[email protected] >https://lists.sourceforge.net/lists/listinfo/enlightenment-devel -- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
