diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-15 13:43:46 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-15 13:43:46 -0500 |
| commit | 317b8f53193e5ec14c92e229c89bc84ca32b7810 (patch) | |
| tree | 481ea31ebfedf6915bb59a24fd6c9cb0506abd20 /util.h | |
| parent | 0577469f9c49473fe95eedfa27b0f282ac9ffdb6 (diff) | |
Progress towards environments
Diffstat (limited to 'util.h')
| -rw-r--r-- | util.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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__}) |
