]> www.ginac.de Git - cln.git/blob - src/base/string/cl_spushstring_append.cc
245d7a2b9036e7962549a5d2c8fd27980b0099ff
[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 void cl_spushstring::append (const char * ptr, uintL len)
15 {
16         if (index + len > alloc) {
17                 var uintL newalloc = index+2*len;
18                 if (newalloc < 2*alloc) { newalloc = 2*alloc; }
19                 var char* newbuffer = (char *) cl_malloc_hook(newalloc);
20                 memcpy(newbuffer,buffer,alloc);
21                 cl_free_hook(buffer);
22                 buffer = newbuffer;
23                 alloc = newalloc;
24         }
25         // Now index+len <= alloc.
26         for (uintL count = len; count > 0; count--)
27                 buffer[index++] = *ptr++;
28 }