diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2011-03-18 22:02:03 +0000 |
---|---|---|
committer | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2011-03-18 22:02:03 +0000 |
commit | 3f1fc919883f84e7e248bcb9a28fedbb5797984d (patch) | |
tree | 19d154bcae88ca53c6a275d7e73cc2f8b026cd62 /src/lib/eina_error.c | |
parent | 3e458d3cf4d414318d58b02bbdc7849f1d295764 (diff) | |
download | eina-3f1fc919883f84e7e248bcb9a28fedbb5797984d.tar.gz |
use stringshare in eina_error
the only restriction here is that eina_error_msg_register cannot be used internally by eina prior to stringshare init, but since this does not happen currently there is no problem :)
SVN revision: 57861
Diffstat (limited to 'src/lib/eina_error.c')
-rw-r--r-- | src/lib/eina_error.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lib/eina_error.c b/src/lib/eina_error.c index f273ca5..ff47405 100644 --- a/src/lib/eina_error.c +++ b/src/lib/eina_error.c @@ -41,7 +41,7 @@ * or a lib should manage. Then, when an error can occur, use * eina_error_set(), and when errors are managed, use * eina_error_get(). If eina_error_set() is used to set an error, do - * not forget to call before eina_error_set0), to remove previous set + * not forget to call before eina_error_set(), to remove previous set * errors. * * Here is an example of use: @@ -149,6 +149,7 @@ /* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */ #include "eina_safety_checks.h" #include "eina_error.h" +#include "eina_stringshare.h" /* TODO * + add a wrapper for assert? @@ -269,7 +270,7 @@ eina_error_shutdown(void) for (; eem < eem_end; eem++) if (eem->string_allocated) - free((char *)eem->string); + eina_stringshare_del(eem->string); free(_eina_errors); _eina_errors = NULL; @@ -303,7 +304,7 @@ eina_error_shutdown(void) * @brief Register a new error type. * * @param msg The description of the error. It will be duplicated using - * strdup(). + * eina_stringshare_add(). * @return The unique number identifier for this error. * * This function stores in a list the error message described by @@ -325,7 +326,7 @@ eina_error_msg_register(const char *msg) return 0; eem->string_allocated = EINA_TRUE; - eem->string = strdup(msg); + eem->string = eina_stringshare_add(msg); if (!eem->string) { _eina_errors_count--; @@ -378,7 +379,7 @@ eina_error_msg_static_register(const char *msg) * This function modifies the message associated with @p error and changes * it to @p msg. If the error was previously registered by @ref eina_error_msg_static_register * then the string will not be duplicated, otherwise the previous message - * will be freed and @p msg copied. + * will be unrefed and @p msg copied. * * @see eina_error_msg_register() */ @@ -396,10 +397,10 @@ eina_error_msg_modify(Eina_Error error, const char *msg) { const char *tmp; - if (!(tmp = strdup(msg))) + if (!(tmp = eina_stringshare_add(msg))) return EINA_FALSE; - free((void *)_eina_errors[error - 1].string); + eina_stringshare_del(_eina_errors[error - 1].string); _eina_errors[error - 1].string = tmp; return EINA_TRUE; } |