| 1118 | } |
| 1119 | |
| 1120 | void das_array_init_borrowed ( das_array * arr, void * data, uint32_t count, uint32_t capacity ) { |
| 1121 | memset(arr, 0, sizeof(das_array)); |
| 1122 | array_mark_locked(*(Array *)arr, data, count, capacity); |
| 1123 | // Set `flags.shared=true` so das_array_lock / das_array_unlock become |
| 1124 | // runtime no-ops on this array — short-circuited by the matching guards |
| 1125 | // in array_lock/array_unlock. Prevents a misuse-by-unlock from dropping |
| 1126 | // the lock to 0 and letting a subsequent resize/delete corrupt the |
| 1127 | // C-owned buffer. Resize/delete still check isLocked() (which stays |
| 1128 | // true), so the borrowed contract is preserved. |
| 1129 | ((Array *)arr)->flags |= 1u; // bit 0 == shared |
| 1130 | } |
| 1131 | |
| 1132 | void das_array_init_borrowed_i64 ( das_array * arr, void * data, uint64_t count, uint64_t capacity ) { |
| 1133 | memset(arr, 0, sizeof(das_array)); |
no test coverage detected