summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/stc/ccommon.h6
-rw-r--r--include/stc/cdeq.h6
-rw-r--r--include/stc/cvec.h6
3 files changed, 11 insertions, 7 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index e21589ea..dd2401a9 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -148,9 +148,9 @@ STC_INLINE uint64_t c_hash64(const void* key, size_t len) {
; it.ref != it##_end_.ref; C##_next(&it))
#define c_forpair(key, val, C, cnt) /* structured binding */ \
- for (struct {C##_iter _it, _end; C##_key key; C##_mapped val;} \
- _ = {C##_begin(&cnt), C##_end(&cnt)} \
- ; _._it.ref != _._end.ref && (_.key = _._it.ref->first, _.val = _._it.ref->second, true) \
+ for (struct {C##_iter _it; C##_value* _endref; C##_key key; C##_mapped val;} \
+ _ = {C##_begin(&cnt), C##_end(&cnt).ref} \
+ ; _._it.ref != _._endref && (_.key = _._it.ref->first, _.val = _._it.ref->second, true) \
; C##_next(&_._it))
#define c_forrange(...) c_MACRO_OVERLOAD(c_forrange, __VA_ARGS__)
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index 74662043..fb4f4ffb 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -249,9 +249,11 @@ _cx_memb(_shrink_to_fit)(_cx_self *self) {
STC_DEF void
_cx_memb(_drop)(_cx_self* self) {
+ struct cdeq_rep* rep = cdeq_rep_(self);
+ // second test to supress gcc -O2 warn: -Wfree-nonheap-object
+ if (rep->cap == 0 || rep == &_cdeq_sentinel) return;
_cx_memb(_clear)(self);
- if (cdeq_rep_(self)->cap)
- c_free(cdeq_rep_(self));
+ c_free(rep);
}
STC_DEF size_t
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index ec2db626..9da2ba56 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -254,9 +254,11 @@ _cx_memb(_clear)(_cx_self* self) {
STC_DEF void
_cx_memb(_drop)(_cx_self* self) {
- if (!cvec_rep_(self)->cap) return;
+ struct cvec_rep* rep = cvec_rep_(self);
+ // second test to supress gcc -O2 warn: -Wfree-nonheap-object
+ if (rep->cap == 0 || rep == &_cvec_sentinel) return;
_cx_memb(_clear)(self);
- c_free(cvec_rep_(self));
+ c_free(rep);
}
STC_DEF bool