summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension/list.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-29 16:53:52 -0600
committerTavian Barnes <tavianator@gmail.com>2010-04-30 09:52:34 -0600
commit5fa471d6842b46ca7c20ebc454065cdaf7488bdb (patch)
tree7a56e30232165fbffd8bbf993373548263205f27 /libdimension/dimension/list.h
parentaeaa9a4e80244a5c66b1afe7e6ee1bcf48e70766 (diff)
downloaddimension-5fa471d6842b46ca7c20ebc454065cdaf7488bdb.tar.xz
Use dmnsn_assert() for array and list range checks.
Diffstat (limited to 'libdimension/dimension/list.h')
-rw-r--r--libdimension/dimension/list.h22
1 files changed, 7 insertions, 15 deletions
diff --git a/libdimension/dimension/list.h b/libdimension/dimension/list.h
index deb7622..5c7d700 100644
--- a/libdimension/dimension/list.h
+++ b/libdimension/dimension/list.h
@@ -95,16 +95,14 @@ dmnsn_list_last(dmnsn_list *list)
DMNSN_INLINE dmnsn_list_iterator *
dmnsn_list_prev(dmnsn_list_iterator *i)
{
- if (!i)
- dmnsn_error(DMNSN_SEVERITY_HIGH, "NULL list iterator.");
+ dmnsn_assert(i, "NULL list iterator.");
return i->prev;
}
DMNSN_INLINE dmnsn_list_iterator *
dmnsn_list_next(dmnsn_list_iterator *i)
{
- if (!i)
- dmnsn_error(DMNSN_SEVERITY_HIGH, "NULL list iterator.");
+ dmnsn_assert(i, "NULL list iterator.");
return i->next;
}
@@ -118,8 +116,7 @@ dmnsn_list_size(dmnsn_list *list)
DMNSN_INLINE void
dmnsn_list_get(const dmnsn_list_iterator *i, void *obj)
{
- if (!i)
- dmnsn_error(DMNSN_SEVERITY_HIGH, "NULL list iterator.");
+ dmnsn_assert(i, "NULL list iterator.");
memcpy(obj, i->ptr, i->obj_size);
}
@@ -127,8 +124,7 @@ dmnsn_list_get(const dmnsn_list_iterator *i, void *obj)
DMNSN_INLINE void
dmnsn_list_set(dmnsn_list_iterator *i, const void *obj)
{
- if (!i)
- dmnsn_error(DMNSN_SEVERITY_HIGH, "NULL list iterator.");
+ dmnsn_assert(i, "NULL list iterator.");
memcpy(i->ptr, obj, i->obj_size);
}
@@ -136,9 +132,8 @@ dmnsn_list_set(dmnsn_list_iterator *i, const void *obj)
DMNSN_INLINE void
dmnsn_list_insert(dmnsn_list *list, dmnsn_list_iterator *i, const void *obj)
{
- if (!i)
- dmnsn_error(DMNSN_SEVERITY_HIGH, "NULL list iterator.");
dmnsn_list_iterator *j = dmnsn_new_list_iterator(obj, list->obj_size);
+ dmnsn_assert(i, "NULL list iterator.");
if (list->first == i)
list->first = j;
j->next = i;
@@ -151,8 +146,7 @@ dmnsn_list_insert(dmnsn_list *list, dmnsn_list_iterator *i, const void *obj)
DMNSN_INLINE void
dmnsn_list_remove(dmnsn_list *list, dmnsn_list_iterator *i)
{
- if (!i)
- dmnsn_error(DMNSN_SEVERITY_HIGH, "NULL list iterator.");
+ dmnsn_assert(i, "NULL list iterator.");
if (list->first == i)
list->first = i->next;
if (list->last == i)
@@ -184,9 +178,7 @@ dmnsn_list_push(dmnsn_list *list, const void *obj)
DMNSN_INLINE void
dmnsn_list_pop(dmnsn_list *list, void *obj)
{
- if (!list->last) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "List is empty.");
- }
+ dmnsn_assert(list->last, "List is empty.");
dmnsn_list_get(list->last, obj);
dmnsn_list_remove(list, list->last);
}