665efa1b5abccac5e1d9cff811e4085de033b5ea
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2019-2020 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #define FIXED_MAP_SIZE 10
41 struct value_t
*values
;
43 /* This field is used only by the pretty printer. */
50 struct map_t
**values
;
52 /* This field is used only by the pretty printer. */
57 create_map (const char *name
)
59 struct map_t
*m
= malloc (sizeof (struct map_t
));
60 m
->name
= strdup (name
);
68 add_map_element (struct map_t
*m
, struct key_t k
, struct value_t v
)
72 m
->keys
= malloc (sizeof (struct key_t
) * FIXED_MAP_SIZE
);
73 m
->values
= malloc (sizeof (struct value_t
) * FIXED_MAP_SIZE
);
76 m
->keys
[m
->length
] = k
;
77 m
->values
[m
->length
] = v
;
84 struct map_map_t
*mm
= malloc (sizeof (struct map_map_t
));
91 add_map_map_element (struct map_map_t
*mm
, struct map_t
*map
)
94 mm
->values
= malloc (sizeof (struct map_t
*) * FIXED_MAP_SIZE
);
96 mm
->values
[mm
->length
] = map
;
103 struct map_t
*m1
= create_map ("m1");
104 struct key_t k1
= {3, 4};
105 struct key_t k2
= {4, 5};
106 struct key_t k3
= {5, 6};
107 struct key_t k4
= {6, 7};
108 struct key_t k5
= {7, 8};
109 struct key_t k6
= {8, 9};
110 struct value_t v1
= {0, 1, 2};
111 struct value_t v2
= {3, 4, 5};
112 struct value_t v3
= {6, 7, 8};
113 struct value_t v4
= {9, 0, 1};
114 struct value_t v5
= {2, 3, 4};
115 struct value_t v6
= {5, 6, 7};
116 add_map_element (m1
, k1
, v1
);
117 add_map_element (m1
, k2
, v2
);
118 add_map_element (m1
, k3
, v3
);
120 struct map_t
*m2
= create_map ("m2");
121 add_map_element (m2
, k4
, v4
);
122 add_map_element (m2
, k5
, v5
);
123 add_map_element (m2
, k6
, v6
);
125 struct map_map_t
*mm
= create_map_map ();
126 add_map_map_element (mm
, m1
);
127 add_map_map_element (mm
, m2
);
129 return 0; /* Break here. */
This page took 0.0436299999999999 seconds and 3 git commands to generate.