]> www.ginac.de Git - cln.git/blob - src/base/string/cl_st_make1.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / base / string / cl_st_make1.cc
1 // cl_make_heap_string().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/string.h"
8
9
10 // Implementation.
11
12 #include "cln/malloc.h"
13 #include "cl_offsetof.h"
14
15 namespace cln {
16
17 cl_heap_string* cl_make_heap_string (const char * s)
18 {
19         var unsigned long len = ::strlen(s);
20         var cl_heap_string* str = (cl_heap_string*) malloc_hook(offsetofa(cl_heap_string,data)+sizeof(char)*(len+1));
21         str->refcount = 1;
22         str->type = &cl_class_string;
23         str->length = len;
24         {
25                 var const char* ptr1 = s;
26                 var char* ptr2 = &str->data[0];
27                 var uintL count;
28                 for (count = len; count > 0; count--)
29                         *ptr2++ = *ptr1++;
30                 *ptr2++ = '\0';
31         }
32         return str;
33 }
34
35 }  // namespace cln