/** * @brief Register a new error type, statically allocated message. * * @param msg The description of the error. This string will not be * duplicated and thus the given pointer should live during * usage of eina_error. * @return The unique number identifier for this error. * * This function stores in a list the error message described by * @p msg. The returned value is a unique identifier greater or equal * than 1. The description can be retrieve later by passing to * eina_error_msg_get() the returned value. * * @see eina_error_msg_register() */ EAPI Eina_Error eina_error_msg_static_register(const char *msg) { Eina_Error_Message *eem; EINA_SAFETY_ON_NULL_RETURN_VAL(msg, 0); eem = _eina_error_msg_alloc(); if (!eem) return 0; eem->string_allocated = EINA_FALSE; eem->string = msg; return _eina_errors_count; /* identifier = index + 1 (== _count). */ }
EAPI Eina_Error eina_error_msg_register(const char *msg) { Eina_Error_Message *eem; EINA_SAFETY_ON_NULL_RETURN_VAL(msg, 0); eem = _eina_error_msg_alloc(); if (!eem) return 0; eem->string_allocated = EINA_TRUE; eem->string = eina_stringshare_add(msg); if (!eem->string) { _eina_errors_count--; return 0; } return _eina_errors_count; /* identifier = index + 1 (== _count). */ }