MCPcopy Create free account
hub / github.com/F-Stack/f-stack / read_cache_begin

Function read_cache_begin

adapter/micro_thread/mt_cache.cpp:640–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

638}
639
640uint32_t read_cache_begin(TBuffVecPtr multi, uint32_t begin, void* data, uint32_t len)
641{
642 TRWCache* cache = (TRWCache*)multi;
643 if (NULL == cache) {
644 return 0;
645 }
646
647 if (begin >= cache->len) {
648 return 0;
649 }
650
651 uint32_t pos_left = begin;
652 uint32_t copy_left = len;
653 uint32_t offset = 0;
654 TSkBuffer* item = NULL;
655 TAILQ_FOREACH(item, &cache->list, entry)
656 {
657 uint8_t* start_ptr = item->data;
658 uint32_t real_left = item->data_len;
659 if (pos_left > 0)
660 {
661 uint32_t skip_len = pos_left > real_left ? real_left : pos_left;
662 pos_left -= skip_len;
663 real_left -= skip_len;
664 start_ptr += skip_len;
665 }
666
667 if (real_left == 0)
668 {
669 continue;
670 }
671
672 uint32_t copy_len = copy_left > real_left ? real_left : copy_left;
673 if (data != NULL)
674 {
675 memcpy((char*)data + offset, start_ptr, copy_len);
676 }
677 offset += copy_len;
678 copy_left -= copy_len;
679 if (copy_left == 0)
680 {
681 break;
682 }
683 }
684
685 return offset;
686}
687
688};

Callers 1

ExtendRecvRspMethod · 0.85

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected