MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / das_array_init_borrowed

Function das_array_init_borrowed

src/misc/daScriptC.cpp:1120–1130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1118}
1119
1120void 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
1132void das_array_init_borrowed_i64 ( das_array * arr, void * data, uint64_t count, uint64_t capacity ) {
1133 memset(arr, 0, sizeof(das_array));

Callers 2

mainFunction · 0.85

Calls 1

array_mark_lockedFunction · 0.85

Tested by

no test coverage detected