summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-04-27 13:23:10 +0200
committerTyge Løvset <[email protected]>2022-04-27 13:23:10 +0200
commit8178a02c4048cef03952a075f87da91b6ec2ee96 (patch)
treebc5b9a2fc2c64ae5a1b3eb665e828e4246707247 /include
parente6738b3da5cbd7703cf3fbd905b3fdac19d0ae24 (diff)
downloadSTC-modified-8178a02c4048cef03952a075f87da91b6ec2ee96.tar.gz
STC-modified-8178a02c4048cef03952a075f87da91b6ec2ee96.zip
Finally FIXED cloning/to/from scheme to work properly. When using i_key_bind/i_val_bind, a .._clone() function *must* always be defined.
Functions .._from and .._toraw is only required when i_keyraw/i_valraw type is defined.
Diffstat (limited to 'include')
-rw-r--r--include/stc/cstack.h8
-rw-r--r--include/stc/template.h20
2 files changed, 17 insertions, 11 deletions
diff --git a/include/stc/cstack.h b/include/stc/cstack.h
index f2412184..ee283cec 100644
--- a/include/stc/cstack.h
+++ b/include/stc/cstack.h
@@ -76,6 +76,14 @@ STC_INLINE bool _cx_memb(_reserve)(_cx_self* self, size_t n) {
return t ? (self->data = t, self->capacity = n) : 0;
}
+STC_INLINE _cx_value*
+_cx_memb(_expand_uninitialized)(_cx_self *self, size_t n) {
+ size_t len = self->size;
+ if (!_cx_memb(_reserve)(self, len + n)) return NULL;
+ self->size += n;
+ return self->data + len;
+}
+
STC_INLINE void _cx_memb(_shrink_to_fit)(_cx_self* self)
{ _cx_memb(_reserve)(self, self->size); }
diff --git a/include/stc/template.h b/include/stc/template.h
index a523d07c..31360946 100644
--- a/include/stc/template.h
+++ b/include/stc/template.h
@@ -122,11 +122,10 @@
#ifdef i_key_bind
#define i_key i_key_bind
- #ifndef i_keyraw
- #ifndef i_keyfrom
- #define i_keyfrom c_paste(i_key, _clone)
- #endif
- #else
+ #ifndef i_keyclone
+ #define i_keyclone c_paste(i_key, _clone)
+ #endif
+ #ifdef i_keyraw
#ifndef i_keyfrom
#define i_keyfrom c_paste(i_key, _from)
#endif
@@ -156,7 +155,7 @@
#ifndef i_tag
#define i_tag i_key
#endif
-#if (!defined i_keyfrom && defined i_keydrop) || c_option(c_no_clone)
+#if c_option(c_no_clone)
#define _i_no_clone
#endif
#ifndef i_keyfrom
@@ -210,11 +209,10 @@
#ifdef i_val_bind
#define i_val i_val_bind
- #ifndef i_valraw
- #ifndef i_valfrom
- #define i_valfrom c_paste(i_val, _clone)
- #endif
- #else
+ #ifndef i_valclone
+ #define i_valclone c_paste(i_val, _clone)
+ #endif
+ #ifdef i_valraw
#ifndef i_valfrom
#define i_valfrom c_paste(i_val, _from)
#endif