diff options
| author | Tyge Løvset <[email protected]> | 2021-11-03 13:20:59 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-11-03 13:20:59 +0100 |
| commit | 1790465d3dc002beafb91cc52d8aa6319dc67b35 (patch) | |
| tree | 435fd45459b5bf1f71cdd95b88e411dd90c67f24 | |
| parent | 27a6860137499e71eb23c1930ebe6e992baece12 (diff) | |
| download | STC-modified-1790465d3dc002beafb91cc52d8aa6319dc67b35.tar.gz STC-modified-1790465d3dc002beafb91cc52d8aa6319dc67b35.zip | |
Removed carrN_elem(). Added assert in carrN_at().
| -rw-r--r-- | docs/carray_api.md | 2 | ||||
| -rw-r--r-- | include/stc/carr2.h | 9 | ||||
| -rw-r--r-- | include/stc/carr3.h | 9 |
3 files changed, 8 insertions, 12 deletions
diff --git a/docs/carray_api.md b/docs/carray_api.md index 65c4588f..aa9ea681 100644 --- a/docs/carray_api.md +++ b/docs/carray_api.md @@ -33,7 +33,6 @@ void carr2_X_del(carr2_X* self); size_t carr2_X_size(carr2_X arr); i_val* carr2_X_data(carr2_X* self); // access storage data -i_val* carr2_X_elem(carr2_X* self, size_t x, size_t y); const i_val* carr2_X_at(const carr2_X* self, size_t x, size_t y); carr2_X_iter carr2_X_begin(const carr2_X* self); @@ -52,7 +51,6 @@ void carr3_X_del(carr3_X* self); size_t carr3_X_size(carr3_X arr); i_val* carr3_X_data(carr3_X* self); // storage data -i_val* carr3_X_elem(carr3_X* self, size_t x, size_t y, size_t z); const i_val* carr3_X_at(const carr3_X* self, size_t x, size_t y, size_t z); carr3_X_iter carr3_X_begin(const carr3_X* self); 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; |
