2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libgo / runtime / go-map-len.c
blob7da10c249437216aa3950f0febb31c38ac9b437a
1 /* go-map-len.c -- return the length of a map.
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>
9 #include "runtime.h"
10 #include "go-assert.h"
11 #include "map.h"
13 /* Return the length of a map. This could be done inline, of course,
14 but I'm doing it as a function for now to make it easy to change
15 the map structure. */
17 intgo
18 __go_map_len (struct __go_map *map)
20 if (map == NULL)
21 return 0;
22 __go_assert (map->__element_count
23 == (uintptr_t) (intgo) map->__element_count);
24 return map->__element_count;