MCPcopy Create free account
hub / github.com/SIPp/sipp / merge_socketbufs

Function merge_socketbufs

src/socket.cpp:637–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635#define CFM_CRLFCRLF 5 /* We've found the end of the headers! */
636
637static void merge_socketbufs(struct socketbuf* socketbuf)
638{
639 struct socketbuf *next = socketbuf->next;
640 int newsize;
641 char *newbuf;
642
643 if (!next) {
644 return;
645 }
646
647 if (next->offset) {
648 ERROR("Internal error: can not merge a socketbuf with a non-zero offset.");
649 }
650
651 if (socketbuf->offset) {
652 memmove(socketbuf->buf, socketbuf->buf + socketbuf->offset, socketbuf->len - socketbuf->offset);
653 socketbuf->len -= socketbuf->offset;
654 socketbuf->offset = 0;
655 }
656
657 newsize = socketbuf->len + next->len;
658
659 newbuf = (char *)realloc(socketbuf->buf, newsize);
660 if (!newbuf) {
661 ERROR("Could not allocate memory to merge socket buffers!");
662 }
663 memcpy(newbuf + socketbuf->len, next->buf, next->len);
664 socketbuf->buf = newbuf;
665 socketbuf->len = newsize;
666 socketbuf->next = next->next;
667 free_socketbuf(next);
668}
669
670/* Check for a message in the socket and return the length of the first
671 * message. If this is UDP, the only check is if we have buffers. If this is

Callers 1

check_for_messageMethod · 0.85

Calls 2

ERRORFunction · 0.85
free_socketbufFunction · 0.85

Tested by

no test coverage detected