diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/carr2.h | 9 | ||||
| -rw-r--r-- | include/stc/carr3.h | 9 |
2 files changed, 8 insertions, 10 deletions
diff --git a/include/stc/carr2.h b/include/stc/carr2.h index a1dfc3ce..b961c47e 100644 --- a/include/stc/carr2.h +++ b/include/stc/carr2.h @@ -76,11 +76,10 @@ STC_INLINE size_t _cx_memb(_size)(_cx_self arr) STC_INLINE _cx_value *_cx_memb(_data)(_cx_self* self) { return *self->data; } -STC_INLINE _cx_value *_cx_memb(_elem)(_cx_self* self, size_t x, size_t y) - { return *self->data + self->ydim*x + y; } - -STC_INLINE const _cx_value *_cx_memb(_at)(const _cx_self* self, size_t x, size_t y) - { return *self->data + self->ydim*x + y; } +STC_INLINE const _cx_value *_cx_memb(_at)(const _cx_self* self, size_t x, size_t y) { + assert(x < self->xdim && y < self->ydim); + return *self->data + self->ydim*x + y; +} STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { if (self->data == other.data) return; diff --git a/include/stc/carr3.h b/include/stc/carr3.h index 4d4fc84e..3f230204 100644 --- a/include/stc/carr3.h +++ b/include/stc/carr3.h @@ -78,11 +78,10 @@ STC_INLINE size_t _cx_memb(_size)(_cx_self arr) STC_INLINE _cx_value* _cx_memb(_data)(_cx_self* self) { return **self->data; } -STC_INLINE _cx_value* _cx_memb(_elem)(_cx_self* self, size_t x, size_t y, size_t z) - { return **self->data + self->zdim*(self->ydim*x + y) + z; } - -STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, size_t x, size_t y, size_t z) - { return **self->data + self->zdim*(self->ydim*x + y) + z; } +STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, size_t x, size_t y, size_t z) { + assert(x < self->xdim && y < self->ydim && z < self->zdim); + return **self->data + self->zdim*(self->ydim*x + y) + z; +} STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { if (self->data == other.data) return; |
