]> www.ginac.de Git - cln.git/blob - src/base/string/cl_spushstring_append.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / base / string / cl_spushstring_append.cc
1 // class cl_spushstring.
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_spushstring.h"
8
9
10 // Implementation.
11
12 #include <string.h> // declares memcpy()
13
14 namespace cln {
15
16 void cl_spushstring::append (const char * ptr, uintL len)
17 {
18         if (index + len > alloc) {
19                 var uintL newalloc = index+2*len;
20                 if (newalloc < 2*alloc) { newalloc = 2*alloc; }
21                 var char* newbuffer = (char *) malloc_hook(newalloc);
22                 memcpy(newbuffer,buffer,alloc);
23                 free_hook(buffer);
24                 buffer = newbuffer;
25                 alloc = newalloc;
26         }
27         // Now index+len <= alloc.
28         for (uintL count = len; count > 0; count--)
29                 buffer[index++] = *ptr++;
30 }
31
32 }  // namespace cln