summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--stc/cdeq.h5
-rw-r--r--stc/cvec.h3
2 files changed, 3 insertions, 5 deletions
diff --git a/stc/cdeq.h b/stc/cdeq.h
index 398edea3..0eced527 100644
--- a/stc/cdeq.h
+++ b/stc/cdeq.h
@@ -233,10 +233,9 @@ static struct cdeq_rep _cdeq_inits = {0, 0};
self->data = self->_base + nfront; \
} \
size_t pos = (cap - (len + n)) / 2; \
+ if (!at_front && nfront < pos) return; \
if (at_front && nback < pos) pos += pos - nback; \
- else if (!at_front && nfront < pos) pos = nfront; \
- if (pos != nfront) \
- self->data = (CX##_value_t *) memmove(self->_base + pos, self->data, len*sizeof(Value)); \
+ self->data = (CX##_value_t *) memmove(self->_base + pos, self->data, len*sizeof(Value)); \
} \
\
STC_DEF void \
diff --git a/stc/cvec.h b/stc/cvec.h
index b42474f6..5102d6e8 100644
--- a/stc/cvec.h
+++ b/stc/cvec.h
@@ -46,7 +46,6 @@
struct cvec_rep { size_t size, cap; void* data[]; };
#define _cvec_rep(self) c_container_of((self)->data, struct cvec_rep, data)
-typedef int (*c_cmp_fn)(const void*, const void*);
#define _c_using_cvec(CX, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue) \
@@ -172,7 +171,7 @@ typedef int (*c_cmp_fn)(const void*, const void*);
STC_INLINE void \
CX##_sort_range(CX##_iter_t i1, CX##_iter_t i2, \
int(*cmp)(const CX##_value_t*, const CX##_value_t*)) { \
- qsort(i1.ref, i2.ref - i1.ref, sizeof(CX##_value_t), (c_cmp_fn) cmp); \
+ qsort(i1.ref, i2.ref - i1.ref, sizeof(CX##_value_t), (int(*)(const void*, const void*)) cmp); \
} \
STC_INLINE void \
CX##_sort(CX* self) { \