X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Falloc.h;h=89e1dab7c83e5a04385589b4f3539201d9681a14;hb=refs%2Fheads%2Fmaster;hp=2c7e6a041b56dae49d70735184335bc7bce17865;hpb=3eadff410d2d08246d6f195ef209ed9d88c99be5;p=muddle-interpreter.git diff --git a/src/alloc.h b/src/alloc.h index 2c7e6a0..89e1dab 100644 --- a/src/alloc.h +++ b/src/alloc.h @@ -28,16 +28,26 @@ typedef int32_t heap_ptr; typedef union pool_object pool_object; typedef union object object; +typedef union uv_val uv_val; pool_object *POOL_OBJECT (pool_ptr p); object *HEAP_OBJECT (heap_ptr p); +uv_val *UV_VAL (heap_ptr p); pool_ptr pool_alloc (uint32_t len); heap_ptr heap_alloc (uint32_t len); +inline static heap_ptr +heap_alloc_uv (uint32_t len) +{ + // divide by 2 (rounding up), then add one for dope + return heap_alloc (((len + 1) >> 1) + 1); +} // given a headerless array of objects of known size, -// copy it backwards into newly-allocated pool space -pool_ptr pool_copy_array_rev (const pool_object *objs, uint32_t len); -heap_ptr heap_copy_array_rev (const object *objs, uint32_t len); +// copy it into newly-allocated pool space +pool_ptr pool_copy_array (const pool_object * objs, uint32_t len); +// same as above, but backwards +pool_ptr pool_copy_array_rev (const pool_object * objs, uint32_t len); +heap_ptr heap_copy_array_rev (const object * objs, uint32_t len); #endif // ALLOC_H