diff options
| author | Tyge Løvset <[email protected]> | 2021-10-23 12:29:43 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-10-23 12:29:43 +0200 |
| commit | 0f95c005891b0d4b3b2610fdba241cf78c372d81 (patch) | |
| tree | ebf3cebe3ef6dc66f820ab063b1cc3a3b7861a38 /include | |
| parent | 63a09f6492b022eccd1583fd9b69c450ae3a8935 (diff) | |
| download | STC-modified-0f95c005891b0d4b3b2610fdba241cf78c372d81.tar.gz STC-modified-0f95c005891b0d4b3b2610fdba241cf78c372d81.zip | |
Fixed bug in c_realloc() call ion cstack. Added assert in cmap_X_at(). Added a c++ example.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cdeq.h | 6 | ||||
| -rw-r--r-- | include/stc/cmap.h | 1 | ||||
| -rw-r--r-- | include/stc/cstack.h | 5 |
3 files changed, 9 insertions, 3 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index 0157f967..264761e0 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -108,11 +108,13 @@ STC_INLINE cx_value_t* cx_memb(_emplace_front)(Self* self, i_valraw raw) { }
STC_INLINE void cx_memb(_pop_back)(Self* self) {
- cx_value_t* p = &self->data[--cdeq_rep_(self)->size]; i_valdel(p);
+ cx_value_t* p = &self->data[--cdeq_rep_(self)->size];
+ i_valdel(p);
}
STC_INLINE cx_value_t* cx_memb(_at)(const Self* self, size_t idx) {
- assert(idx < cdeq_rep_(self)->size); return self->data + idx;
+ assert(idx < cdeq_rep_(self)->size);
+ return self->data + idx;
}
STC_INLINE size_t cx_memb(_index)(Self cx, cx_iter_t it) {
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 5bfee69a..7e4e64eb 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -120,6 +120,7 @@ cx_MAP_ONLY( STC_INLINE cx_mapped_t*
cx_memb(_at)(const Self* self, i_keyraw rkey) {
chash_bucket_t b = cx_memb(_bucket_)(self, &rkey);
+ assert(self->_hashx[b.idx]);
return &self->table[b.idx].second;
}
)
diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 3283eaf0..e461ca4b 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -78,7 +78,7 @@ STC_INLINE void cx_memb(_pop)(Self* self) STC_INLINE void cx_memb(_reserve)(Self* self, size_t n) {
if (n >= self->size)
- self->data = (cx_value_t *)c_realloc(self->data, (self->capacity = n)*sizeof(cx_rawvalue_t));
+ self->data = (cx_value_t *)c_realloc(self->data, (self->capacity = n)*sizeof(cx_value_t));
}
STC_INLINE void cx_memb(_shrink_to_fit)(Self* self)
@@ -93,6 +93,9 @@ STC_INLINE cx_value_t* cx_memb(_push)(Self* self, cx_value_t val) { STC_INLINE cx_value_t* cx_memb(_emplace)(Self* self, cx_rawvalue_t raw)
{ return cx_memb(_push)(self, i_valfrom(raw)); }
+STC_INLINE cx_value_t* cx_memb(_at)(const Self* self, size_t idx)
+ { assert(idx < self->size); return self->data + idx; }
+
STC_INLINE Self cx_memb(_clone)(Self v) {
Self out = {(cx_value_t *) c_malloc(v.size*sizeof(cx_value_t)), v.size, v.size};
for (size_t i = 0; i < v.size; ++i, ++v.data) out.data[i] = i_valfrom(i_valto(v.data));
|
