Lines Matching refs:map
19 static void mappings_init(struct mappings *map) in mappings_init() argument
21 map->n = 0; in mappings_init()
22 map->nalloc = 0; in mappings_init()
23 map->entries = 0; in mappings_init()
26 static void mappings_destroy(struct mappings *map) in mappings_destroy() argument
28 if (map->entries) in mappings_destroy()
29 free(map->entries); in mappings_destroy()
32 static int mappings_grow(struct mappings *map) in mappings_grow() argument
34 if (map->n >= map->nalloc) { in mappings_grow()
36 size_t n = map->nalloc << 1, a; in mappings_grow()
39 else if (n <= map->n) in mappings_grow()
41 a = sizeof(*map->entries) * n; in mappings_grow()
42 if (a / n != sizeof(*map->entries)) in mappings_grow()
44 new_entries = realloc(map->entries, a); in mappings_grow()
47 map->entries = new_entries; in mappings_grow()
48 map->nalloc = n; in mappings_grow()
53 static int mappings_add(struct mappings *map, int cp_uni, int cp_932) in mappings_add() argument
56 size_t s = 0, e = map->n; in mappings_add()
61 entry = &map->entries[i]; in mappings_add()
64 int r = mappings_grow(map); in mappings_add()
67 if (map->n > i) { in mappings_add()
68 size_t n = map->n - i, a = sizeof(*map->entries) * n; in mappings_add()
69 if (a / n != sizeof(*map->entries)) in mappings_add()
71 memmove(&map->entries[i + 1], &map->entries[i], a); in mappings_add()
73 ++map->n; in mappings_add()
74 entry = &map->entries[i]; in mappings_add()
82 int r = mappings_grow(map); in mappings_add()
85 if (map->n > i + 1) { in mappings_add()
86 size_t n = (map->n - i - 1), a = sizeof(*map->entries) * n; in mappings_add()
87 if (a / n != sizeof(*map->entries)) in mappings_add()
89 memmove(&map->entries[i + 2], &map->entries[i + 1], a); in mappings_add()
91 ++map->n; in mappings_add()
92 entry = &map->entries[i + 1]; in mappings_add()
384 struct mappings map; in main() local
406 mappings_init(&map); in main()
475 if (mappings_add(&map, cp_uni, cp_932)) { in main()
485 for (i = 0; i < map.n; ++i) in main()
486 gen->visitor(&map.entries[i]); in main()
491 mappings_destroy(&map); in main()