masaori335 commented on code in PR #11456:
URL: https://github.com/apache/trafficserver/pull/11456#discussion_r1673560881


##########
src/iocore/cache/P_CacheDoc.h:
##########
@@ -96,3 +104,58 @@ Doc::data()
 {
   return this->hdr() + this->hlen;
 }
+
+static char *
+iobufferblock_memcpy(char *p, int len, IOBufferBlock const *ab, int offset)
+{
+  IOBufferBlock const *b = ab;
+  while (b && len >= 0) {
+    char *start      = b->_start;
+    char *end        = b->_end;
+    int   max_bytes  = end - start;
+    max_bytes       -= offset;
+    if (max_bytes <= 0) {
+      offset = -max_bytes;
+      b      = b->next.get();
+      continue;
+    }
+    int bytes = len;
+    if (bytes >= max_bytes) {
+      bytes = max_bytes;
+    }
+    ::memcpy(p, start + offset, bytes);
+    p      += bytes;
+    len    -= bytes;
+    b       = b->next.get();
+    offset  = 0;
+  }
+  return p;
+}
+
+inline void

Review Comment:
   Is there any reason to have there functions are defined in file instead of 
cc file? 
   
   Especially, if this `Doc::set_data` is in the cc file, it looks like we can 
put the `iobufferblock_memcpy` function in the unnamed namespace.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to