1 /* go-append.c -- the go builtin append function.
3 Copyright 2010 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. */
13 struct __go_open_array
14 __go_append (const struct __go_slice_type *type,
15 struct __go_open_array a, struct __go_open_array b)
21 if (b.__values == NULL || b.__count == 0)
24 __go_assert (type->__common.__code == GO_SLICE);
25 element_size = type->__element_type->__size;
27 ucount = (unsigned int) a.__count + (unsigned int) b.__count;
29 __go_assert (ucount == (unsigned int) count && count >= a.__count);
30 if (count > a.__capacity)
33 struct __go_open_array n;
50 n.__values = __go_alloc (m * element_size);
51 n.__count = a.__count;
53 __builtin_memcpy (n.__values, a.__values, n.__count * element_size);
58 __builtin_memmove ((char *) a.__values + a.__count * element_size,
59 b.__values, b.__count * element_size);