| 80 | } |
| 81 | |
| 82 | void Record_Clone |
| 83 | ( |
| 84 | const Record r, |
| 85 | Record clone |
| 86 | ) { |
| 87 | int entry_count = Record_length(r); |
| 88 | size_t required_record_size = sizeof(Entry) * entry_count; |
| 89 | |
| 90 | memcpy(clone->entries, r->entries, required_record_size); |
| 91 | |
| 92 | /* Foreach scalar entry in cloned record, make sure it is not freed. |
| 93 | * it is the original record owner responsibility to free the record |
| 94 | * and its internal scalar as a result. |
| 95 | * |
| 96 | * TODO: I wish we wouldn't have to perform this loop as it is a major performance hit |
| 97 | * with the introduction of a garbage collection this should be removed. */ |
| 98 | for(int i = 0; i < entry_count; i++) { |
| 99 | if(Record_GetType(clone, i) == REC_TYPE_SCALAR) { |
| 100 | SIValue_MakeVolatile(&clone->entries[i].value.s); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | void Record_DeepClone |
| 106 | ( |
no test coverage detected