diff options
| author | Tyge Løvset <[email protected]> | 2022-01-03 15:04:58 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-01-03 15:04:58 +0100 |
| commit | 562a351011c022435d7e61e0068e61f50c4fe2d3 (patch) | |
| tree | d31a52844c50afd18d4cc16d20086419d453c57e | |
| parent | 783dca2d34af4327b528769c304f0f3fbff97a7d (diff) | |
| download | STC-modified-562a351011c022435d7e61e0068e61f50c4fe2d3.tar.gz STC-modified-562a351011c022435d7e61e0068e61f50c4fe2d3.zip | |
Removed many warnings (mainly linux), and some minors.
| -rw-r--r-- | checkauto.ll | 1 | ||||
| -rw-r--r-- | include/stc/carr3.h | 4 | ||||
| -rw-r--r-- | include/stc/csmap.h | 21 | ||||
| -rw-r--r-- | include/stc/cstr.h | 12 | ||||
| -rw-r--r-- | include/stc/cvec.h | 4 | ||||
| -rw-r--r-- | include/stc/forward.h | 24 |
6 files changed, 34 insertions, 32 deletions
diff --git a/checkauto.ll b/checkauto.ll index 1a8e1450..83e939bb 100644 --- a/checkauto.ll +++ b/checkauto.ll @@ -56,6 +56,7 @@ if { if (state == BRACESDONE) { state = BRACES; } } +;[ \t]*else ; ; { if (state == BRACESDONE) { block_type = block[block_lev]; state = NORMAL; diff --git a/include/stc/carr3.h b/include/stc/carr3.h index ef5dc303..f34fb94f 100644 --- a/include/stc/carr3.h +++ b/include/stc/carr3.h @@ -108,8 +108,8 @@ STC_DEF _cx_self _cx_memb(_with_storage)(size_t xdim, size_t ydim, size_t zdim, _cx_self _arr = {c_alloc_n(_cx_value**, xdim*(ydim + 1)), xdim, ydim, zdim}; _cx_value** p = (_cx_value**) &_arr.data[xdim]; for (size_t x = 0, y; x < xdim; ++x, p += ydim) - for (_arr.data[x] = p, y = 0; y < ydim; ++y, block += zdim) - _arr.data[x][y] = block; + for (y = 0, _arr.data[x] = p; y < ydim; ++y, block += zdim) + p[y] = block; return _arr; } diff --git a/include/stc/csmap.h b/include/stc/csmap.h index 5bbc6ba4..bdb2ec45 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -253,13 +253,13 @@ _cx_memb(_back)(const _cx_self* self) { STC_DEF bool
_cx_memb(_reserve)(_cx_self* self, const size_t cap) {
- struct csmap_rep* rep = _csmap_rep(self);
+ struct csmap_rep* rep = _csmap_rep(self), *oldrep;
if (cap >= rep->size) {
- _cx_size oldcap = rep->cap;
- rep = (struct csmap_rep*) c_realloc(oldcap ? rep : NULL,
+ oldrep = rep == &_csmap_sentinel ? NULL : rep;
+ rep = (struct csmap_rep*) c_realloc(oldrep,
sizeof(struct csmap_rep) + (cap + 1)*sizeof(_cx_node));
if (!rep) return false;
- if (oldcap == 0)
+ if (oldrep == NULL)
memset(rep, 0, sizeof(struct csmap_rep) + sizeof(_cx_node));
rep->cap = cap;
self->nodes = (_cx_node *) rep->nodes;
@@ -495,19 +495,20 @@ _cx_memb(_clone)(_cx_self tree) { #endif // !c_no_clone
STC_DEF void
-_cx_memb(_del_r_)(_cx_node* d, _cx_size tn) {
+_cx_memb(_drop_r_)(_cx_node* d, _cx_size tn) {
if (tn) {
- _cx_memb(_del_r_)(d, d[tn].link[0]);
- _cx_memb(_del_r_)(d, d[tn].link[1]);
+ _cx_memb(_drop_r_)(d, d[tn].link[0]);
+ _cx_memb(_drop_r_)(d, d[tn].link[1]);
_cx_memb(_value_drop)(&d[tn].value);
}
}
STC_DEF void
_cx_memb(_drop)(_cx_self* self) {
- if (_csmap_rep(self)->root) {
- _cx_memb(_del_r_)(self->nodes, (_cx_size) _csmap_rep(self)->root);
- c_free(_csmap_rep(self));
+ struct csmap_rep* rep = _csmap_rep(self);
+ if (rep != &_csmap_sentinel) {
+ _cx_memb(_drop_r_)(self->nodes, (_cx_size) rep->root);
+ c_free(rep);
}
}
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 8c87cb5a..8881e43b 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -36,10 +36,10 @@ typedef struct cstr_iter { char *ref; } cstr_iter; typedef char cstr_value;
#define cstr_npos (SIZE_MAX >> 1)
-typedef struct { size_t size, cap; char str[sizeof(size_t)]; } _cstr_rep_t;
+typedef struct { size_t size, cap; char str[]; } _cstr_rep_t;
#define _cstr_rep(self) c_container_of((self)->str, _cstr_rep_t, str)
#if defined(_i_static)
- static _cstr_rep_t _cstr_nullrep = {0, 0, {0}};
+ static struct { size_t size, cap; char str[1]; } _cstr_nullrep = {0, 0, {0}};
static const cstr cstr_null = {_cstr_nullrep.str};
#else
extern const cstr cstr_null;
@@ -178,8 +178,8 @@ cstr_ends_with(cstr s, const char* sub) { #if defined(_i_implement)
#if !defined(_i_static)
- static _cstr_rep_t _cstr_nullrep = {0, 0, {0}};
- const cstr cstr_null = {_cstr_nullrep.str}; )
+ static struct { size_t size, cap; char str[1]; } _cstr_nullrep = {0, 0, {0}};
+ const cstr cstr_null = {_cstr_nullrep.str};
#endif
STC_DEF size_t
@@ -207,9 +207,9 @@ STC_DEF cstr cstr_from_n(const char* str, const size_t n) {
if (n == 0) return cstr_null;
_cstr_rep_t* rep = (_cstr_rep_t*) c_malloc(_cstr_opt_mem(n));
- cstr s = {(char *) memcpy(rep->str, str, n)};
- s.str[rep->size = n] = '\0';
+ rep->str[rep->size = n] = '\0';
rep->cap = _cstr_opt_cap(n);
+ cstr s = {(char *) memcpy(rep->str, str, n)};
return s;
}
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 41415419..7d71c515 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -258,9 +258,9 @@ _cx_memb(_clear)(_cx_self* self) { STC_DEF void
_cx_memb(_drop)(_cx_self* self) {
+ if (cvec_rep_(self) == &_cvec_sentinel) return;
_cx_memb(_clear)(self);
- if (cvec_rep_(self)->cap)
- c_free(cvec_rep_(self));
+ c_free(cvec_rep_(self));
}
STC_DEF bool
diff --git a/include/stc/forward.h b/include/stc/forward.h index 9a37297e..66301dfd 100644 --- a/include/stc/forward.h +++ b/include/stc/forward.h @@ -57,18 +57,18 @@ typedef struct { SELF##_value ***data; size_t xdim, ydim, zdim; } SELF
#define _c_cdeq_types(SELF, VAL) \
- typedef VAL SELF##_value, SELF##_value_t; \
- typedef struct {SELF##_value *ref; } SELF##_iter, SELF##_iter_t; \
+ typedef VAL SELF##_value; \
+ typedef struct {SELF##_value *ref; } SELF##_iter; \
typedef struct {SELF##_value *_base, *data;} SELF
#define _c_clist_types(SELF, VAL) \
- typedef VAL SELF##_value, SELF##_value_t; \
+ typedef VAL SELF##_value; \
typedef struct SELF##_node SELF##_node; \
\
typedef struct { \
SELF##_value *ref; \
SELF##_node *const *_last, *prev; \
- } SELF##_iter, SELF##_iter_t; \
+ } SELF##_iter; \
\
typedef struct { \
SELF##_node *last; \
@@ -81,17 +81,17 @@ \
typedef SET_ONLY( SELF##_key ) \
MAP_ONLY( struct SELF##_value ) \
- SELF##_value, SELF##_value_t; \
+ SELF##_value; \
\
typedef struct { \
SELF##_value *ref; \
bool inserted; \
- } SELF##_result, SELF##_result_t; \
+ } SELF##_result; \
\
typedef struct { \
SELF##_value *ref; \
uint8_t* _hx; \
- } SELF##_iter, SELF##_iter_t; \
+ } SELF##_iter; \
\
typedef struct { \
SELF##_value* table; \
@@ -108,19 +108,19 @@ \
typedef SET_ONLY( SELF##_key ) \
MAP_ONLY( struct SELF##_value ) \
- SELF##_value, SELF##_value_t; \
+ SELF##_value; \
\
typedef struct { \
SELF##_value *ref; \
bool inserted; \
- } SELF##_result, SELF##_result_t; \
+ } SELF##_result; \
\
typedef struct { \
SELF##_value *ref; \
SELF##_node *_d; \
int _top; \
SELF##_size_t _tn, _st[36]; \
- } SELF##_iter, SELF##_iter_t; \
+ } SELF##_iter; \
\
typedef struct { \
SELF##_node *nodes; \
@@ -156,8 +156,8 @@ } SELF
#define _c_cvec_types(SELF, VAL) \
- typedef VAL SELF##_value, SELF##_value_t; \
- typedef struct { SELF##_value *ref; } SELF##_iter, SELF##_iter_t; \
+ typedef VAL SELF##_value; \
+ typedef struct { SELF##_value *ref; } SELF##_iter; \
typedef struct { SELF##_value *data; } SELF
#endif // STC_FORWARD_H_INCLUDED
|
