File: insertat.cc

package info (click to toggle)
crossroads 2.65-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,664 kB
  • ctags: 355
  • sloc: cpp: 4,212; perl: 1,658; xml: 269; makefile: 186; sh: 46
file content (20 lines) | stat: -rw-r--r-- 482 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "netbuffer"

bool Netbuffer::insertat(unsigned index, char const *s, unsigned len) {
    PROFILE("Netbuffer::insertat");
    debugmsg(Mstr("Netbuffer: inserting ") + Mstr(s) + Mstr(" at ") +
	     Mstr(index) + "\n");

    if (!len)
	len = strlen(s);

    if (index >= buf_sz)
	return false;
    check_space(len);
    memmove (buf_data + index + len, buf_data + index, buf_sz - index);
    memcpy (buf_data + index, s, len);
    buf_sz += len;
    
    return true;
}