MCPcopy Create free account
hub / github.com/baidu/openrasp / insert

Method insert

agent/php5/utils/double_array_trie.h:307–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305 }
306
307 size_t insert(const std::vector<node_t> &siblings)
308 {
309 if (error_ < 0)
310 return 0;
311
312 size_t begin = 0;
313 size_t pos = _max((size_t)siblings[0].code + 1, next_check_pos_) - 1;
314 size_t nonzero_num = 0;
315 int first = 0;
316
317 if (alloc_size_ <= pos)
318 resize(pos + 1);
319
320 while (true)
321 {
322 next:
323 ++pos;
324
325 if (alloc_size_ <= pos)
326 resize(pos + 1);
327
328 if (array_[pos].check)
329 {
330 ++nonzero_num;
331 continue;
332 }
333 else if (!first)
334 {
335 next_check_pos_ = pos;
336 first = 1;
337 }
338
339 begin = pos - siblings[0].code;
340 if (alloc_size_ <= (begin + siblings[siblings.size() - 1].code))
341 resize(static_cast<size_t>(alloc_size_ *
342 _max(1.05, 1.0 * key_size_ / progress_)));
343
344 if (used_[begin])
345 continue;
346
347 for (size_t i = 1; i < siblings.size(); ++i)
348 if (array_[begin + siblings[i].code].check != 0)
349 goto next;
350
351 break;
352 }
353
354 if (1.0 * nonzero_num / (pos - next_check_pos_ + 1) >= 0.95)
355 next_check_pos_ = pos;
356
357 used_[begin] = 1;
358 size_ = _max(size_, begin + static_cast<size_t>(siblings[siblings.size() - 1].code + 1));
359
360 for (size_t i = 0; i < siblings.size(); ++i)
361 array_[begin + siblings[i].code].check = begin;
362
363 try
364 {

Callers 13

fetch_if_addrsFunction · 0.45
process_eventsMethod · 0.45
process_eventsMethod · 0.45
add_watchMethod · 0.45
preprocess_node_eventMethod · 0.45
decode_flagsFunction · 0.45
get_multipart_strMethod · 0.45
build_snapshotMethod · 0.45
dependency_detectMethod · 0.45

Calls 2

_maxFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected