forked from enlightenment/efl
eina safety checks.
safety checks will report null pointers and other error conditions on public api's and can be disabled by compile time check. note that in order to have these checks working we need to make EINA_ARG_NONNULL() void, otherwise GCC can remove these checks since they're known to be false. This commit also make two minor changes: * list and hash accessors and iterators are created even for empty entities. This is correct in my point of view since NULL should indicate error. Having these in were an optimziation, but not worth it, these are not the most common case and hitting this path is not of much cost. * unmarked some parameters as nonnull, mainly on list and inlist. SVN revision: 38327
This commit is contained in:
parent
b0ee5696a6
commit
ab95d9183d
|
@ -62,6 +62,27 @@ if test "x${enable_magic_debug}" = "xyes" ; then
|
|||
fi
|
||||
AC_SUBST(EINA_MAGIC_DEBUG)
|
||||
|
||||
# Safety checks (avoid crashes on wrong api usage)
|
||||
want_safety_checks="yes"
|
||||
AC_MSG_CHECKING(whether to do safety checking on api parameters)
|
||||
AC_ARG_ENABLE(safety-checks,
|
||||
AC_HELP_STRING(
|
||||
[--disable-safety-checks],
|
||||
[disable safety checks for NULL pointers and like. [[default=enabled]]]
|
||||
),
|
||||
[ want_safety_checks="$enableval" ]
|
||||
)
|
||||
AC_MSG_RESULT($want_safety_checks)
|
||||
|
||||
AM_CONDITIONAL(SAFETY_CHECKS, test "x$want_safety_checks" = "xyes")
|
||||
if test "x$want_safety_checks" = "xyes"; then
|
||||
AC_DEFINE(SAFETY_CHECKS, 1, [disable safety checks for NULL pointers and like.])
|
||||
EINA_SAFETY_CHECKS=1
|
||||
else
|
||||
EINA_SAFETY_CHECKS=0
|
||||
fi
|
||||
AC_SUBST(EINA_SAFETY_CHECKS)
|
||||
|
||||
# Choose best memory pool
|
||||
AC_ARG_ENABLE([default-mempool],
|
||||
[AC_HELP_STRING([--enable-default-mempool], [Default memory allocator could be faster for some computer])],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
EINAHEADERS = \
|
||||
eina_safety_checks.h \
|
||||
eina_error.h \
|
||||
eina_f16p16.h \
|
||||
eina_hash.h \
|
||||
|
|
|
@ -29,4 +29,9 @@
|
|||
#define EINA_DEFAULT_MEMPOOL
|
||||
#endif
|
||||
|
||||
#undef EINA_SAFETY_CHECKS
|
||||
#if @EINA_SAFETY_CHECKS@
|
||||
#define EINA_SAFETY_CHECKS
|
||||
#endif
|
||||
|
||||
#endif /* EINA_CONFIG_H_ */
|
||||
|
|
|
@ -115,14 +115,14 @@ EAPI void eina_hash_foreach(const Eina_Hash *hash,
|
|||
|
||||
/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function
|
||||
used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
|
||||
EAPI int eina_hash_superfast(const char *key, int len);
|
||||
EAPI int eina_hash_superfast(const char *key, int len) EINA_ARG_NONNULL(1);
|
||||
|
||||
/* Hash function first reported by dan bernstein many years ago in comp.lang.c */
|
||||
static inline int eina_hash_djb2(const char *key, int len);
|
||||
static inline int eina_hash_djb2(const char *key, int len) EINA_ARG_NONNULL(1);
|
||||
|
||||
/* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */
|
||||
static inline int eina_hash_int32(unsigned int *pkey, int len);
|
||||
static inline int eina_hash_int64(unsigned long int *pkey, int len);
|
||||
static inline int eina_hash_int32(unsigned int *pkey, int len) EINA_ARG_NONNULL(1);
|
||||
static inline int eina_hash_int64(unsigned long int *pkey, int len) EINA_ARG_NONNULL(1);
|
||||
|
||||
#include "eina_inline_hash.x"
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ struct _Eina_Inlist
|
|||
|
||||
EAPI Eina_Inlist * eina_inlist_append(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_prepend(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_append_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_prepend_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_append_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_prepend_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_remove(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_find(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_find(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_promote(Eina_Inlist *list, Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Inlist * eina_inlist_demote(Eina_Inlist *list, Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
|
||||
|
|
|
@ -81,22 +81,22 @@ EAPI int eina_list_shutdown(void);
|
|||
|
||||
EAPI Eina_List *eina_list_append (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_prepend (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_append_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_append_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_prepend_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_prepend_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_remove (Eina_List *list, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_remove_list (Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_promote_list (Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_data_find_list (const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_free (Eina_List *list) EINA_ARG_NONNULL(1);
|
||||
EAPI void *eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_nth_list (const Eina_List *list, unsigned int n) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_reverse (Eina_List *list) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_sort (Eina_List *list, unsigned int size, Eina_Compare_Cb func) EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_merge (Eina_List *left, Eina_List *right) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_append_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_append_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_prepend_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_prepend_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_remove (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_remove_list (Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_promote_list (Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_data_find_list (const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_free (Eina_List *list);
|
||||
EAPI void *eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_nth_list (const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_reverse (Eina_List *list) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_sort (Eina_List *list, unsigned int size, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_merge (Eina_List *left, Eina_List *right) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
|
||||
|
||||
|
||||
static inline Eina_List *eina_list_last (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
|
||||
|
|
|
@ -56,10 +56,10 @@ typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node, void *data);
|
|||
#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb) Function)
|
||||
|
||||
EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data) EINA_ARG_NONNULL(1, 2);
|
||||
EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data) EINA_ARG_NONNULL(2);
|
||||
|
||||
static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) EINA_PURE EINA_ARG_NONNULL(1, 2, 4) EINA_WARN_UNUSED_RESULT;
|
||||
static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
|
||||
|
||||
EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/* EINA - EFL data type library
|
||||
* Copyright (C) 2008 Gustavo Sverzut Barbieri
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library;
|
||||
* if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EINA_SAFETY_CHECKS_H_
|
||||
#define EINA_SAFETY_CHECKS_H_
|
||||
#ifdef EINA_SAFETY_CHECKS
|
||||
|
||||
#include "eina_error.h"
|
||||
|
||||
#define EINA_SAFETY_ON_NULL_RETURN(exp) \
|
||||
do \
|
||||
{ \
|
||||
if (EINA_UNLIKELY((exp) == NULL)) \
|
||||
{ \
|
||||
EINA_ERROR_PERR("%s", "safety check failed: " #exp " == NULL\n"); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
|
||||
do \
|
||||
{ \
|
||||
if (EINA_UNLIKELY((exp) == NULL)) \
|
||||
{ \
|
||||
EINA_ERROR_PERR("%s", "safety check failed: " #exp " == NULL\n"); \
|
||||
return (val); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
|
||||
do \
|
||||
{ \
|
||||
if (EINA_UNLIKELY(exp)) \
|
||||
{ \
|
||||
EINA_ERROR_PERR("%s", "safety check failed: " #exp " is true\n"); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
|
||||
do \
|
||||
{ \
|
||||
if (EINA_UNLIKELY(exp)) \
|
||||
{ \
|
||||
EINA_ERROR_PERR("%s", "safety check failed: " #exp " is true\n"); \
|
||||
return val; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
|
||||
do \
|
||||
{ \
|
||||
if (EINA_UNLIKELY(!(exp))) \
|
||||
{ \
|
||||
EINA_ERROR_PERR("%s", "safety check failed: " #exp " is false\n"); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
|
||||
do \
|
||||
{ \
|
||||
if (EINA_UNLIKELY(!(exp))) \
|
||||
{ \
|
||||
EINA_ERROR_PERR("%s", "safety check failed: " #exp " is false\n"); \
|
||||
return val; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#ifdef EINA_ARG_NONNULL
|
||||
/* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */
|
||||
#undef EINA_ARG_NONNULL
|
||||
#define EINA_ARG_NONNULL(idx, ...)
|
||||
#endif
|
||||
|
||||
|
||||
#else /* no safety checks */
|
||||
|
||||
#define EINA_SAFETY_ON_NULL_RETURN(exp) \
|
||||
do { (void)((exp) == NULL) } while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
|
||||
do { if (0 && (exp) == NULL) (void)val; } while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
|
||||
do { (void)(exp) } while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
|
||||
do { if (0 && (exp)) (void)val; } while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
|
||||
do { (void)((!exp)) } while (0)
|
||||
|
||||
#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
|
||||
do { if (0 && !(exp)) (void)val; } while (0)
|
||||
|
||||
#endif /* safety checks macros */
|
||||
#endif /* EINA_SAFETY_CHECKS_H_ */
|
|
@ -69,6 +69,12 @@
|
|||
#ifdef EINA_CONST
|
||||
# undef EINA_CONST
|
||||
#endif
|
||||
#ifdef EINA_UNLIKELY
|
||||
# undef EINA_UNLIKELY
|
||||
#endif
|
||||
#ifdef EINA_LIKELY
|
||||
# undef EINA_LIKELY
|
||||
#endif
|
||||
|
||||
#ifdef HAVE___ATTRIBUTE__
|
||||
# ifdef __GNUC__
|
||||
|
@ -78,7 +84,7 @@
|
|||
# define EINA_WARN_UNUSED_RESULT
|
||||
# endif
|
||||
|
||||
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
|
||||
# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
|
||||
# define EINA_ARG_NONNULL(idx, ...) __attribute__ ((nonnull(idx, ## __VA_ARGS__)))
|
||||
# else
|
||||
# define EINA_ARG_NONNULL(idx, ...)
|
||||
|
@ -97,11 +103,15 @@
|
|||
# define EINA_SCANF(fmt, arg) __attribute__((format (scanf, fmt, arg)))
|
||||
# define EINA_FORMAT(fmt) __attribute__((format_arg(fmt)))
|
||||
# define EINA_CONST __attribute__((const))
|
||||
# define EINA_UNLIKELY(exp) __builtin_expect((exp), 0)
|
||||
# define EINA_LIKELY(exp) __builtin_expect((exp), 1)
|
||||
# else
|
||||
# define EINA_PRINTF(fmt, arg)
|
||||
# define EINA_SCANF(fmt, arg)
|
||||
# define EINA_FORMAT(fmt)
|
||||
# define EINA_CONST
|
||||
# define EINA_UNLIKELY(exp)
|
||||
# define EINA_LIKELY(exp)
|
||||
# endif
|
||||
# else /* no __GNUC__ */
|
||||
# define EINA_WARN_UNUSED_RESULT
|
||||
|
@ -112,6 +122,8 @@
|
|||
# define EINA_SCANF(fmt, arg)
|
||||
# define EINA_FORMAT(fmt)
|
||||
# define EINA_CONST
|
||||
# define EINA_UNLIKELY(exp)
|
||||
# define EINA_LIKELY(exp)
|
||||
# endif
|
||||
#else /* no HAVE___ATTRIBUTE__ */
|
||||
# define EINA_WARN_UNUSED_RESULT
|
||||
|
@ -122,6 +134,8 @@
|
|||
# define EINA_SCANF(fmt, arg)
|
||||
# define EINA_FORMAT(fmt)
|
||||
# define EINA_CONST
|
||||
# define EINA_UNLIKELY(exp)
|
||||
# define EINA_LIKELY(exp)
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "eina_private.h"
|
||||
|
||||
#include "eina_accessor.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -92,7 +93,9 @@ EAPI void
|
|||
eina_accessor_free(Eina_Accessor *accessor)
|
||||
{
|
||||
EINA_MAGIC_CHECK_ACCESSOR(accessor);
|
||||
if (accessor) accessor->free(accessor);
|
||||
EINA_SAFETY_ON_NULL_RETURN(accessor);
|
||||
EINA_SAFETY_ON_NULL_RETURN(accessor->free);
|
||||
accessor->free(accessor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,7 +111,8 @@ EAPI void *
|
|||
eina_accessor_container_get(Eina_Accessor *accessor)
|
||||
{
|
||||
EINA_MAGIC_CHECK_ACCESSOR(accessor);
|
||||
if (!accessor) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_container, NULL);
|
||||
return accessor->get_container(accessor);
|
||||
}
|
||||
|
||||
|
@ -129,7 +133,9 @@ EAPI Eina_Bool
|
|||
eina_accessor_data_get(Eina_Accessor *accessor, unsigned int position, void **data)
|
||||
{
|
||||
EINA_MAGIC_CHECK_ACCESSOR(accessor);
|
||||
if (!accessor) return EINA_FALSE;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_at, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
|
||||
return accessor->get_at(accessor, position, data);
|
||||
}
|
||||
|
||||
|
@ -156,16 +162,18 @@ eina_accessor_over(Eina_Accessor *accessor,
|
|||
unsigned int end,
|
||||
const void *fdata)
|
||||
{
|
||||
void *container;
|
||||
const void *container;
|
||||
void *data;
|
||||
unsigned int i;
|
||||
|
||||
EINA_MAGIC_CHECK_ACCESSOR(accessor);
|
||||
EINA_SAFETY_ON_NULL_RETURN(accessor);
|
||||
EINA_SAFETY_ON_NULL_RETURN(accessor->get_container);
|
||||
EINA_SAFETY_ON_NULL_RETURN(accessor->get_at);
|
||||
EINA_SAFETY_ON_NULL_RETURN(cb);
|
||||
EINA_SAFETY_ON_FALSE_RETURN(start < end);
|
||||
|
||||
if (!accessor) return ;
|
||||
if (!(start < end)) return ;
|
||||
|
||||
container = eina_accessor_container_get(accessor);
|
||||
container = accessor->get_container(accessor);
|
||||
for (i = start; i < end && accessor->get_at(accessor, i, &data) == EINA_TRUE; ++i)
|
||||
if (cb(container, data, (void*) fdata) != EINA_TRUE) return ;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "eina_array.h"
|
||||
#include "eina_inline_array.x"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -148,6 +149,7 @@ eina_array_grow(Eina_Array *array)
|
|||
unsigned int total;
|
||||
|
||||
EINA_MAGIC_CHECK_ARRAY(array);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
|
||||
|
||||
total = array->total + array->step;
|
||||
eina_error_set(0);
|
||||
|
@ -318,6 +320,7 @@ eina_array_free(Eina_Array *array)
|
|||
eina_array_flush(array);
|
||||
|
||||
EINA_MAGIC_CHECK_ARRAY(array);
|
||||
EINA_SAFETY_ON_NULL_RETURN(array);
|
||||
MAGIC_FREE(array);
|
||||
}
|
||||
|
||||
|
@ -334,6 +337,7 @@ eina_array_free(Eina_Array *array)
|
|||
EAPI void
|
||||
eina_array_step_set(Eina_Array *array, unsigned int step)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(array);
|
||||
array->data = NULL;
|
||||
array->total = 0;
|
||||
array->count = 0;
|
||||
|
@ -354,6 +358,7 @@ EAPI void
|
|||
eina_array_clean(Eina_Array *array)
|
||||
{
|
||||
EINA_MAGIC_CHECK_ARRAY(array);
|
||||
EINA_SAFETY_ON_NULL_RETURN(array);
|
||||
array->count = 0;
|
||||
}
|
||||
|
||||
|
@ -371,10 +376,12 @@ EAPI void
|
|||
eina_array_flush(Eina_Array *array)
|
||||
{
|
||||
EINA_MAGIC_CHECK_ARRAY(array);
|
||||
EINA_SAFETY_ON_NULL_RETURN(array);
|
||||
array->count = 0;
|
||||
array->total = 0;
|
||||
|
||||
if (array->data) free(array->data);
|
||||
if (!array->data) return;
|
||||
free(array->data);
|
||||
array->data = NULL;
|
||||
}
|
||||
|
||||
|
@ -405,6 +412,9 @@ eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data, void *gdata),
|
|||
unsigned int i;
|
||||
|
||||
EINA_MAGIC_CHECK_ARRAY(array);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(keep, EINA_FALSE);
|
||||
|
||||
if (array->total == 0) return EINA_TRUE;
|
||||
|
||||
for (i = 0; i < array->count; ++i)
|
||||
|
@ -492,7 +502,9 @@ eina_array_iterator_new(const Eina_Array *array)
|
|||
{
|
||||
Eina_Iterator_Array *it;
|
||||
|
||||
if (!array) return NULL;
|
||||
EINA_MAGIC_CHECK_ARRAY(array);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
|
||||
|
||||
if (eina_array_count_get(array) <= 0) return NULL;
|
||||
|
||||
eina_error_set(0);
|
||||
|
@ -531,7 +543,8 @@ eina_array_accessor_new(const Eina_Array *array)
|
|||
{
|
||||
Eina_Accessor_Array *it;
|
||||
|
||||
if (!array) return NULL;
|
||||
EINA_MAGIC_CHECK_ARRAY(array);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
|
||||
|
||||
eina_error_set(0);
|
||||
it = calloc(1, sizeof (Eina_Accessor_Array));
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "eina_convert.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -277,6 +278,8 @@ eina_convert_itoa(int n, char *s)
|
|||
int i = 0;
|
||||
int r = 0;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(s, 0);
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
n = -n;
|
||||
|
@ -316,6 +319,8 @@ eina_convert_xtoa(unsigned int n, char *s)
|
|||
{
|
||||
int i;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(s, 0);
|
||||
|
||||
i = 0;
|
||||
do {
|
||||
s[i++] = look_up_table[n & 0xF];
|
||||
|
@ -379,6 +384,10 @@ eina_convert_atod(const char *src, int length, long long *m, long *e)
|
|||
int nbr_decimals = 0;
|
||||
int sign = 1;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e, EINA_FALSE);
|
||||
|
||||
if (length <= 0) goto on_length_error;
|
||||
|
||||
/* Compute the mantisse. */
|
||||
|
@ -487,6 +496,8 @@ eina_convert_dtoa(double d, char *des)
|
|||
int p;
|
||||
int i;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(des, EINA_FALSE);
|
||||
|
||||
if (d < 0.0)
|
||||
{
|
||||
*(des++) = '-';
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "eina_inlist.h"
|
||||
#include "eina_error.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -299,7 +300,7 @@ eina_counter_add(const char *name)
|
|||
Eina_Counter *counter;
|
||||
int length;
|
||||
|
||||
if (!name) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
||||
|
||||
length = strlen(name) + 1;
|
||||
|
||||
|
@ -330,7 +331,7 @@ eina_counter_add(const char *name)
|
|||
EAPI void
|
||||
eina_counter_delete(Eina_Counter *counter)
|
||||
{
|
||||
if (!counter) return;
|
||||
EINA_SAFETY_ON_NULL_RETURN(counter);
|
||||
|
||||
while (counter->clocks)
|
||||
{
|
||||
|
@ -365,7 +366,7 @@ eina_counter_start(Eina_Counter *counter)
|
|||
Eina_Clock *clk;
|
||||
Eina_Nano_Time tp;
|
||||
|
||||
if (!counter) return;
|
||||
EINA_SAFETY_ON_NULL_RETURN(counter);
|
||||
if (_eina_counter_time_get(&tp) != 0) return;
|
||||
|
||||
eina_error_set(0);
|
||||
|
@ -400,7 +401,7 @@ eina_counter_stop(Eina_Counter *counter, int specimen)
|
|||
Eina_Clock *clk;
|
||||
Eina_Nano_Time tp;
|
||||
|
||||
if (!counter) return;
|
||||
EINA_SAFETY_ON_NULL_RETURN(counter);
|
||||
if (_eina_counter_time_get(&tp) != 0) return;
|
||||
|
||||
clk = (Eina_Clock *) counter->clocks;
|
||||
|
@ -436,7 +437,7 @@ eina_counter_dump(Eina_Counter *counter)
|
|||
char *result = NULL;
|
||||
int position = 0;
|
||||
|
||||
if (!counter) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(counter, NULL);
|
||||
|
||||
result = _eina_counter_asiprintf(result, &position, "# specimen\texperiment time\tstarting time\tending time\n");
|
||||
if (!result) return NULL;
|
||||
|
|
|
@ -361,6 +361,7 @@
|
|||
#include "eina_error.h"
|
||||
#include "eina_inlist.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/* TODO
|
||||
* + printing errors to stdout or stderr can be implemented
|
||||
|
@ -588,6 +589,8 @@ EAPI Eina_Error eina_error_msg_register(const char *msg)
|
|||
Eina_Inlist *tmp;
|
||||
int length;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(msg, 0);
|
||||
|
||||
length = strlen(msg) + 1;
|
||||
|
||||
tmp = malloc(sizeof (Eina_Inlist) + length);
|
||||
|
@ -686,6 +689,10 @@ EAPI void eina_error_print(Eina_Error_Level level, const char *file,
|
|||
if (level > _error_level)
|
||||
return;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(file);
|
||||
EINA_SAFETY_ON_NULL_RETURN(fnc);
|
||||
EINA_SAFETY_ON_NULL_RETURN(fmt);
|
||||
|
||||
va_start(args, fmt);
|
||||
_print_cb(level, file, fnc, line, fmt, _print_cb_data, args);
|
||||
va_end(args);
|
||||
|
|
|
@ -60,6 +60,7 @@ void *alloca (size_t);
|
|||
|
||||
#include "eina_file.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Global *
|
||||
|
@ -114,12 +115,14 @@ void *alloca (size_t);
|
|||
EAPI Eina_Bool
|
||||
eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
|
||||
|
||||
#ifndef _WIN32
|
||||
struct dirent *de;
|
||||
DIR *d;
|
||||
|
||||
if (!cb) return EINA_FALSE;
|
||||
|
||||
d = opendir(dir);
|
||||
if (!d) return EINA_FALSE;
|
||||
|
||||
|
@ -166,9 +169,6 @@ eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb c
|
|||
TCHAR *tdir;
|
||||
int length_dir;
|
||||
|
||||
if (!cb) return EINA_FALSE;
|
||||
if (!dir || (*dir == '\0')) return EINA_FALSE;
|
||||
|
||||
length_dir = strlen(dir);
|
||||
new_dir = (char *)alloca(length_dir + 5);
|
||||
if (!new_dir) return EINA_FALSE;
|
||||
|
@ -248,7 +248,7 @@ eina_file_split(char *path)
|
|||
char *current;
|
||||
int length;
|
||||
|
||||
if (!path) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
||||
|
||||
ea = eina_array_new(16);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "eina_rbtree.h"
|
||||
#include "eina_error.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -190,7 +191,9 @@ eina_hash_add_alloc_by_hash(Eina_Hash *hash,
|
|||
int hash_num;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if ((!hash) || (!key) || (!data)) goto on_error;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
|
||||
error = EINA_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
/* Apply eina mask to hash. */
|
||||
|
@ -385,8 +388,9 @@ _eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int
|
|||
Eina_Hash_Tuple tuple;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return EINA_FALSE;
|
||||
if (!key) return EINA_FALSE;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
||||
|
||||
if (!hash->buckets) return EINA_FALSE;
|
||||
|
||||
tuple.key = (void *) key;
|
||||
|
@ -676,6 +680,7 @@ eina_hash_shutdown(void)
|
|||
eina_error_shutdown();
|
||||
return --_eina_hash_init_count;
|
||||
}
|
||||
|
||||
EAPI Eina_Hash *
|
||||
eina_hash_new(Eina_Key_Length key_length_cb,
|
||||
Eina_Key_Cmp key_cmp_cb,
|
||||
|
@ -687,8 +692,11 @@ eina_hash_new(Eina_Key_Length key_length_cb,
|
|||
Eina_Hash *new;
|
||||
|
||||
eina_error_set(0);
|
||||
if (!key_length_cb || !key_cmp_cb || !key_hash_cb) return NULL;
|
||||
if (buckets_power_size < 3 || buckets_power_size > 16) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key_length_cb, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key_cmp_cb, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key_hash_cb, NULL);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size < 3, NULL);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size > 16, NULL);
|
||||
|
||||
new = malloc(sizeof (Eina_Hash));
|
||||
if (!new) goto on_error;
|
||||
|
@ -789,7 +797,7 @@ EAPI int
|
|||
eina_hash_population(const Eina_Hash *hash)
|
||||
{
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return 0;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, 0);
|
||||
return hash->population;
|
||||
}
|
||||
|
||||
|
@ -817,7 +825,7 @@ eina_hash_free(Eina_Hash *hash)
|
|||
int i;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return;
|
||||
EINA_SAFETY_ON_NULL_RETURN(hash);
|
||||
|
||||
if (hash->buckets)
|
||||
for (i = 0; i < hash->size; i++)
|
||||
|
@ -916,7 +924,11 @@ eina_hash_add(Eina_Hash *hash, const void *key, const void *data)
|
|||
int key_hash;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if ((!hash) || (!key) || (!data)) return EINA_FALSE;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_length_cb, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
|
||||
|
||||
key_length = hash->key_length_cb(key);
|
||||
key_hash = hash->key_hash_cb(key, key_length);
|
||||
|
@ -951,7 +963,11 @@ eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data)
|
|||
int key_hash;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if ((!hash) || (!key) || (!data)) return EINA_FALSE;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_length_cb, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
|
||||
|
||||
key_length = hash->key_length_cb(key);
|
||||
key_hash = hash->key_hash_cb(key, key_length);
|
||||
|
@ -976,6 +992,8 @@ eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data)
|
|||
EAPI Eina_Bool
|
||||
eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
||||
return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, NULL);
|
||||
}
|
||||
|
||||
|
@ -996,6 +1014,8 @@ eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int
|
|||
EAPI Eina_Bool
|
||||
eina_hash_del_by_key(Eina_Hash *hash, const void *key)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
||||
return _eina_hash_del_by_key(hash, key, NULL);
|
||||
}
|
||||
|
||||
|
@ -1019,8 +1039,8 @@ eina_hash_del_by_data(Eina_Hash *hash, const void *data)
|
|||
int key_hash;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return EINA_FALSE;
|
||||
if (!data) return EINA_FALSE;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
|
||||
|
||||
el = _eina_hash_find_by_data(hash, data, &key_hash, &eh);
|
||||
if (!el) return EINA_FALSE;
|
||||
|
@ -1051,6 +1071,8 @@ eina_hash_del_by_data(Eina_Hash *hash, const void *data)
|
|||
EAPI Eina_Bool
|
||||
eina_hash_del_by_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash, const void *data)
|
||||
{
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
if (key) return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, data);
|
||||
else return eina_hash_del_by_data(hash, data);
|
||||
}
|
||||
|
@ -1077,6 +1099,8 @@ eina_hash_del_by_hash(Eina_Hash *hash, const void *key, int key_length, int key_
|
|||
EAPI Eina_Bool
|
||||
eina_hash_del(Eina_Hash *hash, const void *key, const void *data)
|
||||
{
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
|
||||
if (key) return _eina_hash_del_by_key(hash, key, data);
|
||||
else return eina_hash_del_by_data(hash, data);
|
||||
}
|
||||
|
@ -1097,8 +1121,9 @@ eina_hash_find_by_hash(const Eina_Hash *hash, const void *key, int key_length, i
|
|||
Eina_Hash_El *el;
|
||||
Eina_Hash_Tuple tuple;
|
||||
|
||||
if ((!hash) || (!key)) return NULL;
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
||||
|
||||
tuple.key = key;
|
||||
tuple.key_length = key_length;
|
||||
|
@ -1122,8 +1147,11 @@ eina_hash_find(const Eina_Hash *hash, const void *key)
|
|||
int key_length;
|
||||
int hash_num;
|
||||
|
||||
if ((!hash) || (!key)) return NULL;
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_length_cb, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
||||
|
||||
key_length = hash->key_length_cb(key);
|
||||
hash_num = hash->key_hash_cb(key, key_length);
|
||||
|
@ -1151,7 +1179,10 @@ eina_hash_modify_by_hash(Eina_Hash *hash, const void *key, int key_length, int k
|
|||
Eina_Hash_Tuple tuple;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
|
||||
|
||||
tuple.key = key;
|
||||
tuple.key_length = key_length;
|
||||
tuple.data = NULL;
|
||||
|
@ -1182,7 +1213,11 @@ eina_hash_modify(Eina_Hash *hash, const void *key, const void *data)
|
|||
int hash_num;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_length_cb, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
|
||||
|
||||
key_length = hash->key_length_cb(key);
|
||||
hash_num = hash->key_hash_cb(key, key_length);
|
||||
|
@ -1235,7 +1270,8 @@ eina_hash_foreach(const Eina_Hash *hash,
|
|||
Eina_Hash_Foreach_Data foreach;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return;
|
||||
EINA_SAFETY_ON_NULL_RETURN(hash);
|
||||
EINA_SAFETY_ON_NULL_RETURN(func);
|
||||
|
||||
foreach.cb = func;
|
||||
foreach.fdata = fdata;
|
||||
|
@ -1253,8 +1289,7 @@ eina_hash_iterator_data_new(const Eina_Hash *hash)
|
|||
Eina_Iterator_Hash *it;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return NULL;
|
||||
if (hash->population <= 0) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||
|
||||
it = calloc(1, sizeof (Eina_Iterator_Hash));
|
||||
if (!it) return NULL;
|
||||
|
@ -1278,8 +1313,7 @@ eina_hash_iterator_key_new(const Eina_Hash *hash)
|
|||
Eina_Iterator_Hash *it;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return NULL;
|
||||
if (hash->population <= 0) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||
|
||||
it = calloc(1, sizeof (Eina_Iterator_Hash));
|
||||
if (!it) return NULL;
|
||||
|
@ -1303,8 +1337,7 @@ eina_hash_iterator_tuple_new(const Eina_Hash *hash)
|
|||
Eina_Iterator_Hash *it;
|
||||
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
if (!hash) return NULL;
|
||||
if (hash->population <= 0) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||
|
||||
it = calloc(1, sizeof (Eina_Iterator_Hash));
|
||||
if (!it) return NULL;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "eina_inlist.h"
|
||||
#include "eina_error.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/* FIXME: TODO please, refactor this :) */
|
||||
|
||||
|
@ -142,6 +143,8 @@ eina_inlist_append(Eina_Inlist *list, Eina_Inlist *new_l)
|
|||
{
|
||||
Eina_Inlist *l;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
|
||||
|
||||
new_l->next = NULL;
|
||||
if (!list) {
|
||||
new_l->prev = NULL;
|
||||
|
@ -165,6 +168,8 @@ eina_inlist_append(Eina_Inlist *list, Eina_Inlist *new_l)
|
|||
EAPI Eina_Inlist *
|
||||
eina_inlist_prepend(Eina_Inlist *list, Eina_Inlist *new_l)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
|
||||
|
||||
new_l->prev = NULL;
|
||||
if (!list) {
|
||||
new_l->next = NULL;
|
||||
|
@ -186,6 +191,8 @@ eina_inlist_append_relative(Eina_Inlist *list,
|
|||
Eina_Inlist *new_l,
|
||||
Eina_Inlist *relative)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
|
||||
|
||||
if (relative) {
|
||||
if (relative->next) {
|
||||
new_l->next = relative->next;
|
||||
|
@ -209,6 +216,8 @@ eina_inlist_prepend_relative(Eina_Inlist *list,
|
|||
Eina_Inlist *new_l,
|
||||
Eina_Inlist *relative)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
|
||||
|
||||
if (relative) {
|
||||
new_l->prev = relative->prev;
|
||||
new_l->next = relative;
|
||||
|
@ -239,8 +248,8 @@ eina_inlist_remove(Eina_Inlist *list, Eina_Inlist *item)
|
|||
Eina_Inlist *return_l;
|
||||
|
||||
/* checkme */
|
||||
if (!list) return list;
|
||||
if (!item) return list;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
|
||||
|
||||
if (item->next)
|
||||
item->next->prev = item->prev;
|
||||
|
@ -266,8 +275,10 @@ eina_inlist_remove(Eina_Inlist *list, Eina_Inlist *item)
|
|||
EAPI Eina_Inlist *
|
||||
eina_inlist_promote(Eina_Inlist *list, Eina_Inlist *item)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
|
||||
|
||||
if (item == list) return list;
|
||||
if (!item || !list) return list;
|
||||
|
||||
if (item->next)
|
||||
item->next->prev = item->prev;
|
||||
|
@ -294,7 +305,9 @@ eina_inlist_demote(Eina_Inlist *list, Eina_Inlist *item)
|
|||
{
|
||||
Eina_Inlist *l;
|
||||
|
||||
if (!item || !list) return list;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
|
||||
|
||||
if (list->last == item) return list;
|
||||
|
||||
if (!list->last)
|
||||
|
@ -339,8 +352,6 @@ eina_inlist_iterator_new(const Eina_Inlist *list)
|
|||
{
|
||||
Eina_Iterator_Inlist *it;
|
||||
|
||||
if (!list) return NULL;
|
||||
|
||||
eina_error_set(0);
|
||||
it = calloc(1, sizeof (Eina_Iterator_Inlist));
|
||||
if (!it) {
|
||||
|
@ -365,8 +376,6 @@ eina_inlist_accessor_new(const Eina_Inlist *list)
|
|||
{
|
||||
Eina_Accessor_Inlist *it;
|
||||
|
||||
if (!list) return NULL;
|
||||
|
||||
eina_error_set(0);
|
||||
it = calloc(1, sizeof (Eina_Accessor_Inlist));
|
||||
if (!it) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "eina_private.h"
|
||||
|
||||
#include "eina_iterator.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -93,7 +94,9 @@ EAPI void
|
|||
eina_iterator_free(Eina_Iterator *iterator)
|
||||
{
|
||||
EINA_MAGIC_CHECK_ITERATOR(iterator);
|
||||
if (iterator) iterator->free(iterator);
|
||||
EINA_SAFETY_ON_NULL_RETURN(iterator);
|
||||
EINA_SAFETY_ON_NULL_RETURN(iterator->free);
|
||||
iterator->free(iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +112,8 @@ EAPI void *
|
|||
eina_iterator_container_get(Eina_Iterator *iterator)
|
||||
{
|
||||
EINA_MAGIC_CHECK_ITERATOR(iterator);
|
||||
if (!iterator) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->get_container, NULL);
|
||||
return iterator->get_container(iterator);
|
||||
}
|
||||
|
||||
|
@ -130,6 +134,9 @@ eina_iterator_next(Eina_Iterator *iterator, void **data)
|
|||
{
|
||||
if (!iterator) return EINA_FALSE;
|
||||
EINA_MAGIC_CHECK_ITERATOR(iterator);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->next, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
|
||||
return iterator->next(iterator, data);
|
||||
}
|
||||
|
||||
|
@ -150,12 +157,14 @@ eina_iterator_foreach(Eina_Iterator *iterator,
|
|||
Eina_Each cb,
|
||||
const void *fdata)
|
||||
{
|
||||
void *container;
|
||||
const void *container;
|
||||
void *data;
|
||||
|
||||
if (!iterator) return ;
|
||||
|
||||
EINA_MAGIC_CHECK_ITERATOR(iterator);
|
||||
EINA_SAFETY_ON_NULL_RETURN(iterator);
|
||||
EINA_SAFETY_ON_NULL_RETURN(iterator->get_container);
|
||||
EINA_SAFETY_ON_NULL_RETURN(iterator->next);
|
||||
EINA_SAFETY_ON_NULL_RETURN(cb);
|
||||
|
||||
container = iterator->get_container(iterator);
|
||||
while (iterator->next(iterator, &data) == EINA_TRUE) {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "eina_lalloc.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -65,6 +66,9 @@ EAPI Eina_Lalloc * eina_lalloc_new(void *data, Eina_Lalloc_Alloc alloc_cb, Eina_
|
|||
{
|
||||
Eina_Lalloc *a;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(alloc_cb, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(free_cb, NULL);
|
||||
|
||||
a = calloc(1, sizeof(Eina_Lalloc));
|
||||
a->data = data;
|
||||
a->alloc_cb = alloc_cb;
|
||||
|
@ -79,12 +83,17 @@ EAPI Eina_Lalloc * eina_lalloc_new(void *data, Eina_Lalloc_Alloc alloc_cb, Eina_
|
|||
|
||||
EAPI void eina_lalloc_delete(Eina_Lalloc *a)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(a);
|
||||
EINA_SAFETY_ON_NULL_RETURN(a->free_cb);
|
||||
a->free_cb(a->data);
|
||||
free(a);
|
||||
}
|
||||
|
||||
EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
|
||||
|
||||
if (a->num_elements == a->num_allocated)
|
||||
{
|
||||
if (a->alloc_cb(a->data, (1 << a->acc)) == EINA_TRUE)
|
||||
|
@ -104,6 +113,9 @@ EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a, int num)
|
|||
{
|
||||
int tmp;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
|
||||
|
||||
tmp = a->num_elements + num;
|
||||
if (tmp > a->num_allocated)
|
||||
{
|
||||
|
|
|
@ -76,6 +76,8 @@
|
|||
#include "eina_list.h"
|
||||
#include "eina_mempool.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -498,7 +500,7 @@ eina_list_shutdown(void)
|
|||
* @param data The data to append.
|
||||
* @return A list pointer.
|
||||
*
|
||||
* This function appends @p data to @p list. If @p data is @c NULL, a
|
||||
* This function appends @p data to @p list. If @p list is @c NULL, a
|
||||
* new list is returned. On success, a new list pointer that should be
|
||||
* used in place of the one given to this function is
|
||||
* returned. Otherwise, the old pointer is returned.
|
||||
|
@ -553,7 +555,7 @@ eina_list_append(Eina_List *list, const void *data)
|
|||
* @param data The data to prepend.
|
||||
* @return A list pointer.
|
||||
*
|
||||
* This function prepends @p data to @p list. If @p data is @c NULL, a
|
||||
* This function prepends @p data to @p list. If @p list is @c NULL, a
|
||||
* new list is returned. On success, a new list pointer that should be
|
||||
* used in place of the one given to this function is
|
||||
* returned. Otherwise, the old pointer is returned.
|
||||
|
@ -1242,8 +1244,8 @@ eina_list_sort(Eina_List *list, unsigned int size, Eina_Compare_Cb func)
|
|||
Eina_List *unsort = NULL;
|
||||
Eina_List *stack[EINA_LIST_SORT_STACK_SIZE];
|
||||
|
||||
if (!list || !func) return NULL;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(func, list);
|
||||
if (!list) return NULL;
|
||||
EINA_MAGIC_CHECK_LIST(list);
|
||||
|
||||
/* if the caller specified an invalid size, sort the whole list */
|
||||
|
@ -1376,9 +1378,10 @@ eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func)
|
|||
Eina_List *ret;
|
||||
Eina_List *current;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
|
||||
|
||||
if (!left) return right;
|
||||
if (!right) return left;
|
||||
if (!func) return NULL;
|
||||
|
||||
if (func(left->data, right->data) < 0)
|
||||
{
|
||||
|
@ -1460,8 +1463,6 @@ eina_list_iterator_new(const Eina_List *list)
|
|||
{
|
||||
Eina_Iterator_List *it;
|
||||
|
||||
if (!list) return NULL;
|
||||
|
||||
eina_error_set(0);
|
||||
it = calloc(1, sizeof (Eina_Iterator_List));
|
||||
if (!it) {
|
||||
|
@ -1499,8 +1500,6 @@ eina_list_accessor_new(const Eina_List *list)
|
|||
{
|
||||
Eina_Accessor_List *it;
|
||||
|
||||
if (!list) return NULL;
|
||||
|
||||
eina_error_set(0);
|
||||
it = calloc(1, sizeof (Eina_Accessor_List));
|
||||
if (!it) {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "eina_hash.h"
|
||||
#include "eina_module.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -202,7 +203,7 @@ eina_mempool_new(const char *name, const char *context, const char *options, ...
|
|||
Eina_Mempool *mp;
|
||||
va_list args;
|
||||
|
||||
if (!name) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
||||
|
||||
va_start(args, options);
|
||||
mp = _new_from_buffer(name, context, options, args);
|
||||
|
@ -216,24 +217,22 @@ eina_mempool_new(const char *name, const char *context, const char *options, ...
|
|||
*/
|
||||
EAPI void eina_mempool_delete(Eina_Mempool *mp)
|
||||
{
|
||||
if (!mp) return ;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(mp);
|
||||
EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);
|
||||
mp->backend.shutdown(mp->backend_data);
|
||||
free(mp);
|
||||
}
|
||||
|
||||
EAPI void eina_mempool_gc(Eina_Mempool *mp)
|
||||
{
|
||||
assert(mp);
|
||||
assert(mp->backend.garbage_collect);
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(mp);
|
||||
EINA_SAFETY_ON_NULL_RETURN(mp->backend.garbage_collect);
|
||||
mp->backend.garbage_collect(mp->backend_data);
|
||||
}
|
||||
|
||||
EAPI void eina_mempool_statistics(Eina_Mempool *mp)
|
||||
{
|
||||
assert(mp);
|
||||
assert(mp->backend.statistics);
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(mp);
|
||||
EINA_SAFETY_ON_NULL_RETURN(mp->backend.statistics);
|
||||
mp->backend.statistics(mp->backend_data);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "eina_module.h"
|
||||
#include "eina_file.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -177,6 +178,8 @@ EAPI Eina_Bool eina_module_load(Eina_Module *m)
|
|||
void *dl_handle;
|
||||
Eina_Module_Init *initcall;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
|
||||
|
||||
if (m->handle) goto loaded;
|
||||
|
||||
eina_error_set(EINA_ERROR_WRONG_MODULE);
|
||||
|
@ -209,7 +212,7 @@ loaded:
|
|||
EAPI Eina_Bool eina_module_unload(Eina_Module *m)
|
||||
{
|
||||
Eina_Module_Shutdown *shut;
|
||||
if (!m) return EINA_FALSE;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
|
||||
|
||||
m->ref--;
|
||||
if (!m->ref)
|
||||
|
@ -231,6 +234,7 @@ EAPI Eina_Module * eina_module_new(const char *file)
|
|||
{
|
||||
Eina_Module *m;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
|
||||
/* TODO check that the file exists */
|
||||
|
||||
m = malloc(sizeof(Eina_Module));
|
||||
|
@ -247,7 +251,7 @@ EAPI Eina_Module * eina_module_new(const char *file)
|
|||
*/
|
||||
EAPI Eina_Bool eina_module_delete(Eina_Module *m)
|
||||
{
|
||||
if (!m) return EINA_FALSE;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
|
||||
|
||||
if (m->handle)
|
||||
{
|
||||
|
@ -264,9 +268,8 @@ EAPI Eina_Bool eina_module_delete(Eina_Module *m)
|
|||
*/
|
||||
EAPI void * eina_module_symbol_get(Eina_Module *m, const char *symbol)
|
||||
{
|
||||
if ((!m) || (!m->handle))
|
||||
return NULL;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(m->handle, NULL);
|
||||
return dlsym(m->handle, symbol);
|
||||
}
|
||||
/**
|
||||
|
@ -275,13 +278,14 @@ EAPI void * eina_module_symbol_get(Eina_Module *m, const char *symbol)
|
|||
*/
|
||||
EAPI const char * eina_module_file_get(Eina_Module *m)
|
||||
{
|
||||
if (!m) return NULL;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
|
||||
return m->file;
|
||||
}
|
||||
|
||||
EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(symbol, NULL);
|
||||
|
||||
#ifdef HAVE_DLADDR
|
||||
Dl_info eina_dl;
|
||||
|
||||
|
@ -318,6 +322,8 @@ EAPI char *eina_module_environment_path_get(const char *env, const char *sub_dir
|
|||
{
|
||||
const char *env_dir;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(env, NULL);
|
||||
|
||||
env_dir = getenv(env);
|
||||
if (env_dir)
|
||||
{
|
||||
|
@ -358,8 +364,7 @@ EAPI Eina_Array * eina_module_list_get(Eina_Array *array, const char *path, unsi
|
|||
Dir_List_Get_Cb_Data list_get_cb_data;
|
||||
Dir_List_Cb_Data list_cb_data;
|
||||
|
||||
if (!path)
|
||||
return array;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
||||
|
||||
list_get_cb_data.array = array ? array : eina_array_new(4);
|
||||
list_get_cb_data.cb = cb;
|
||||
|
@ -382,6 +387,8 @@ EAPI void eina_module_list_load(Eina_Array *array)
|
|||
Eina_Module *m;
|
||||
unsigned int i;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(array);
|
||||
|
||||
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
|
||||
eina_module_load(m);
|
||||
}
|
||||
|
@ -395,6 +402,8 @@ EAPI void eina_module_list_unload(Eina_Array *array)
|
|||
Eina_Module *m;
|
||||
unsigned int i;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(array);
|
||||
|
||||
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
|
||||
eina_module_unload(m);
|
||||
}
|
||||
|
@ -408,6 +417,8 @@ EAPI void eina_module_list_delete(Eina_Array *array)
|
|||
Eina_Module *m;
|
||||
unsigned int i;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(array);
|
||||
|
||||
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
|
||||
eina_module_delete(m);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "eina_rbtree.h"
|
||||
#include "eina_array.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -161,8 +162,6 @@ _eina_rbtree_iterator_build(const Eina_Rbtree *root, unsigned char mask)
|
|||
Eina_Iterator_Rbtree_List *first;
|
||||
Eina_Iterator_Rbtree *it;
|
||||
|
||||
if (!root) return NULL;
|
||||
|
||||
it = calloc(1, sizeof (Eina_Iterator_Rbtree));
|
||||
if (!it) return NULL;
|
||||
|
||||
|
@ -249,6 +248,9 @@ eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_
|
|||
Eina_Rbtree *p, *q; /* Iterator & parent */
|
||||
Eina_Rbtree_Direction dir, last;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(cmp, root);
|
||||
|
||||
if (!node) return root;
|
||||
|
||||
_eina_rbtree_node_init(node);
|
||||
|
@ -328,6 +330,9 @@ eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_
|
|||
Eina_Rbtree *f = NULL;
|
||||
Eina_Rbtree_Direction dir;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(cmp, root);
|
||||
|
||||
if (!root || !node) return root;
|
||||
|
||||
memset(&head, 0, sizeof(Eina_Rbtree));
|
||||
|
@ -455,6 +460,8 @@ eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data)
|
|||
{
|
||||
if (!root) return ;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(func);
|
||||
|
||||
eina_rbtree_delete(root->son[0], func, data);
|
||||
eina_rbtree_delete(root->son[1], func, data);
|
||||
func(root, data);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "eina_magic.h"
|
||||
#include "eina_inlist.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
@ -223,7 +224,7 @@ eina_rectangle_pool_delete(Eina_Rectangle_Pool *pool)
|
|||
{
|
||||
Eina_Rectangle_Alloc *del;
|
||||
|
||||
if (!pool) return ;
|
||||
EINA_SAFETY_ON_NULL_RETURN(pool);
|
||||
while (pool->head)
|
||||
{
|
||||
del = (Eina_Rectangle_Alloc*) pool->head;
|
||||
|
@ -239,7 +240,7 @@ eina_rectangle_pool_delete(Eina_Rectangle_Pool *pool)
|
|||
EAPI int
|
||||
eina_rectangle_pool_count(Eina_Rectangle_Pool *pool)
|
||||
{
|
||||
if (!pool) return 0;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, 0);
|
||||
return pool->references;
|
||||
}
|
||||
|
||||
|
@ -252,7 +253,8 @@ eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h)
|
|||
int x;
|
||||
int y;
|
||||
|
||||
if (!pool) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, NULL);
|
||||
|
||||
if (w > pool->w || h > pool->h) return NULL;
|
||||
|
||||
test = _eina_rectangle_pool_find((Eina_Rectangle_Alloc*) pool->head, pool->w, pool->h, w, h, &x, &y);
|
||||
|
@ -279,6 +281,8 @@ eina_rectangle_pool_release(Eina_Rectangle *rect)
|
|||
{
|
||||
Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(rect);
|
||||
|
||||
EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
|
||||
EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
|
||||
|
||||
|
@ -293,7 +297,7 @@ eina_rectangle_pool_get(Eina_Rectangle *rect)
|
|||
{
|
||||
Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
|
||||
|
||||
if (!rect) return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(rect, NULL);
|
||||
|
||||
EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
|
||||
EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
|
||||
|
@ -304,9 +308,8 @@ eina_rectangle_pool_get(Eina_Rectangle *rect)
|
|||
EAPI void
|
||||
eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data)
|
||||
{
|
||||
if (!pool) return ;
|
||||
|
||||
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
||||
EINA_SAFETY_ON_NULL_RETURN(pool);
|
||||
|
||||
pool->data = (void*) data;
|
||||
}
|
||||
|
@ -314,9 +317,8 @@ eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data)
|
|||
EAPI void *
|
||||
eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool)
|
||||
{
|
||||
if (!pool) return NULL;
|
||||
|
||||
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, NULL);
|
||||
|
||||
return pool->data;
|
||||
}
|
||||
|
@ -327,6 +329,7 @@ eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h)
|
|||
if (!pool) return EINA_FALSE;
|
||||
|
||||
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, EINA_FALSE);
|
||||
|
||||
if (w) *w = pool->w;
|
||||
if (h) *h = pool->h;
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#include "eina_error.h"
|
||||
#include "eina_private.h"
|
||||
#include "eina_magic.h"
|
||||
#include "eina_safety_checks.h"
|
||||
|
||||
/*============================================================================*
|
||||
* Local *
|
||||
|
|
Loading…
Reference in New Issue