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

Function das_table_clear

src/misc/daScriptC.cpp:1268–1282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1266}
1267
1268void das_table_clear ( das_context * context, das_table * tab, int key_base_type, uint32_t value_size ) {
1269 auto * t = (Table *)tab;
1270 if ( t->isLocked() ) {
1271 ((Context *)context)->throw_error("can't clear locked table");
1272 return;
1273 }
1274 if ( t->data ) {
1275 uint32_t key_size = 0;
1276 DAS_TABLE_DISPATCH(key_base_type, { key_size = sizeof(KEY_TYPE); })
1277 if ( !key_size ) return; // throw_error already raised
1278 uint64_t total = t->capacity * (uint64_t(value_size) + uint64_t(key_size)) + t->capacity*das::tableHashSlotBytes(*t);
1279 ((Context *)context)->free(t->data, total, nullptr);
1280 }
1281 memset(t, 0, sizeof(Table));
1282}
1283
1284// `key` may point at unaligned bytes (a key inside a packed buffer, an
1285// offset inside a serialization stream, …) — copy into an aligned local

Callers 3

test_capi_i64.cppFile · 0.85
mainFunction · 0.85

Calls 4

tableHashSlotBytesFunction · 0.85
isLockedMethod · 0.80
throw_errorMethod · 0.80
freeMethod · 0.45

Tested by

no test coverage detected