* doc/sourcebuild.texi (Ada Tests): Adjust reference to ACATS
[official-gcc.git] / libgo / runtime / go-strplus.c
blobe4dea9c4690ac4bd1afbbf974fe05bc8faee08f7
1 /* go-strplus.c -- the go string append function.
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
7 #include "go-string.h"
8 #include "runtime.h"
9 #include "malloc.h"
11 struct __go_string
12 __go_string_plus (struct __go_string s1, struct __go_string s2)
14 int len;
15 unsigned char *retdata;
16 struct __go_string ret;
18 if (s1.__length == 0)
19 return s2;
20 else if (s2.__length == 0)
21 return s1;
23 len = s1.__length + s2.__length;
24 retdata = runtime_mallocgc (len, FlagNoPointers, 1, 0);
25 __builtin_memcpy (retdata, s1.__data, s1.__length);
26 __builtin_memcpy (retdata + s1.__length, s2.__data, s2.__length);
27 ret.__data = retdata;
28 ret.__length = len;
29 return ret;