aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-15 13:43:46 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-15 13:43:46 -0500
commit317b8f53193e5ec14c92e229c89bc84ca32b7810 (patch)
tree481ea31ebfedf6915bb59a24fd6c9cb0506abd20 /util.h
parent0577469f9c49473fe95eedfa27b0f282ac9ffdb6 (diff)
Progress towards environments
Diffstat (limited to 'util.h')
-rw-r--r--util.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/util.h b/util.h
index 68ce2c9f..34acb8ff 100644
--- a/util.h
+++ b/util.h
@@ -9,6 +9,7 @@
#define streq(a, b) (((a) == NULL && (b) == NULL) || (((a) == NULL) == ((b) == NULL) && strcmp(a, b) == 0))
#define new(t, ...) ((t*)memcpy(GC_MALLOC(sizeof(t)), &(t){__VA_ARGS__}, sizeof(t)))
+#define copy(obj_ptr) ((__typeof(obj_ptr))memcpy(GC_MALLOC(sizeof(*(obj_ptr))), obj_ptr, sizeof(*(obj_ptr))))
#define grow(arr, new_size) ((typeof (arr))GC_REALLOC(arr, (sizeof(arr[0]))*(new_size)))
#define Match(x, _tag) ((x)->tag == _tag ? &(x)->__data._tag : (errx(1, __FILE__ ":%d This was supposed to be a " # _tag "\n", __LINE__), &(x)->__data._tag))
#define Tagged(t, _tag, ...) new(t, .tag=_tag, .__data._tag={__VA_ARGS__})