In gcc/objc/: 2011-04-12 Nicola Pero <nicola.pero@meta-innovation.com>
[official-gcc.git] / libgo / runtime / go-construct-map.c
blob15497eadb5d219b516a8b6fb6c06ff8fc4d469a5
1 /* go-construct-map.c -- construct a map from an initializer.
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 <stddef.h>
8 #include <stdlib.h>
10 #include "map.h"
12 struct __go_map *
13 __go_construct_map (const struct __go_map_descriptor *descriptor,
14 size_t count, size_t entry_size, size_t val_offset,
15 size_t val_size, const void *ventries)
17 struct __go_map *ret;
18 const unsigned char *entries;
19 size_t i;
21 ret = __go_new_map (descriptor, count);
23 entries = (const unsigned char *) ventries;
24 for (i = 0; i < count; ++i)
26 void *val = __go_map_index (ret, entries, 1);
27 __builtin_memcpy (val, entries + val_offset, val_size);
28 entries += entry_size;
31 return ret;