IntClone
Description
Create a deep copy of an integer.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to clone |
Usage example (from documentation)
Int copy = IntClone(&value);Success
Returns an independent deep copy of value’s bit-vector, normalised, and bound to value’s allocator. value is not modified.
Failure
Returns a freshly initialised empty Int bound to value’s allocator on allocation failure during the bit-vector copy. The caller cannot distinguish that from a true zero result; use IntTryClone directly when explicit failure propagation is required.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:145:
static SignedInt sint_clone(SignedInt *value) {
SignedInt clone = {.negative = value->negative, .magnitude = IntClone(&value->magnitude)};
sint_normalize(&clone);
return clone;- In
Int.c:460:
}
Int IntClone(const Int *value) {
Int clone;- In
Int.c:741:
}
current = IntClone(value);
if (IntIsZero(¤t)) {
return false;- In
Int.Type.c:47:
bool test_int_clone(void) {
WriteFmt("Testing IntClone\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Type.c:52:
Int original = IntFromBinary("1011", &alloc.base);
Int clone = IntClone(&original);
bool result = IntEQ(&clone, &original);- In
Int.Type.c:70:
bool test_int_clone_inherits_allocator_config(void) {
WriteFmt("Testing IntClone allocator inheritance\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Type.c:85:
BitVecPush(&original.bits, true);
Int clone = IntClone(&original);
bool result =
Last updated on