mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-12-05 21:27:13 -06:00
some vec tweaks
This commit is contained in:
14
vec.h
14
vec.h
@@ -1,7 +1,7 @@
|
||||
#define VEC_STRUCT(typename,inttype) \
|
||||
struct typename { \
|
||||
inttype *buf; \
|
||||
size_t len, alen; \
|
||||
size_t len,alen; \
|
||||
}
|
||||
VEC_STRUCT(vec_basestruct,void) ;
|
||||
|
||||
@@ -24,8 +24,8 @@ void vec_addn(struct vec_basestruct *ctl,size_t sz,size_t n);
|
||||
#define VEC_REMOVEN(ctl,n,m) { \
|
||||
(ctl).len -= m; \
|
||||
memmove( \
|
||||
&(ctl).buf[(n)], \
|
||||
&(ctl).buf[(n + m)], \
|
||||
&(ctl).buf[n], \
|
||||
&(ctl).buf[(n) + (m)], \
|
||||
((ctl).len - (n)) * VEC_ELSIZE(ctl)); \
|
||||
}
|
||||
#define VEC_REMOVE(ctl,n) VEC_REMOVEN(ctl,n,1)
|
||||
@@ -33,8 +33,8 @@ void vec_addn(struct vec_basestruct *ctl,size_t sz,size_t n);
|
||||
#define VEC_INSERT1(ctl,n) { \
|
||||
VEC_ADD1(ctl); \
|
||||
memmove( \
|
||||
&(ctl).buf[(n + 1)], \
|
||||
&(ctl).buf[(n)], \
|
||||
&(ctl).buf[(n) + 1], \
|
||||
&(ctl).buf[n], \
|
||||
((ctl).len - (n) - 1) * VEC_ELSIZE(ctl)); \
|
||||
}
|
||||
#define VEC_INSERT(ctl,n,val) { \
|
||||
@@ -45,8 +45,8 @@ void vec_addn(struct vec_basestruct *ctl,size_t sz,size_t n);
|
||||
#define VEC_INSERTN(ctl,n,m) { \
|
||||
VEC_ADDN(ctl,m); \
|
||||
memmove( \
|
||||
&(ctl).buf[(n + m)], \
|
||||
&(ctl).buf[(n)], \
|
||||
&(ctl).buf[(n) + (m)], \
|
||||
&(ctl).buf[n], \
|
||||
((ctl).len - (n) - (m)) * VEC_ELSIZE(ctl)); \
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user