]> www.ginac.de Git - cln.git/blob - src/base/string/cl_spushstring_push.cc
29cb91f7ab65a4376985cbe41245d8cfb3898370
[cln.git] / src / base / string / cl_spushstring_push.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::push (char c)
15 {
16         if (index >= alloc) {
17                 var uintL newalloc = 2*alloc;
18                 var char* newbuffer = (char *) cl_malloc_hook(newalloc);
19                 memcpy(newbuffer,buffer,alloc);
20                 cl_free_hook(buffer);
21                 buffer = newbuffer;
22                 alloc = newalloc;
23         }
24         // Now index < alloc.
25         buffer[index++] = c;
26 }