MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / bitmap_init

Function bitmap_init

mysys/my_bitmap.c:138–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136
137
138my_bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
139 my_bool thread_safe __attribute__((unused)))
140{
141 DBUG_ENTER("bitmap_init");
142 if (!buf)
143 {
144 uint size_in_bytes= bitmap_buffer_size(n_bits);
145 uint extra= 0;
146
147 if (thread_safe)
148 {
149 size_in_bytes= ALIGN_SIZE(size_in_bytes);
150 extra= sizeof(mysql_mutex_t);
151 }
152 map->mutex= 0;
153
154 if (!(buf= (my_bitmap_map*) my_malloc(size_in_bytes+extra, MYF(MY_WME))))
155 DBUG_RETURN(1);
156
157 if (thread_safe)
158 {
159 map->mutex= (mysql_mutex_t *) ((char*) buf + size_in_bytes);
160 mysql_mutex_init(key_BITMAP_mutex, map->mutex, MY_MUTEX_INIT_FAST);
161 }
162
163 }
164
165 else
166 {
167 DBUG_ASSERT(thread_safe == 0);
168 map->mutex= NULL;
169 }
170
171
172 map->bitmap= buf;
173 map->n_bits= n_bits;
174 create_last_word_mask(map);
175 bitmap_clear_all(map);
176 DBUG_RETURN(0);
177}
178
179
180void bitmap_free(MY_BITMAP *map)

Callers 3

mysqld.ccFile · 0.85
initMethod · 0.85
intersectMethod · 0.85

Calls 2

my_mallocFunction · 0.85
create_last_word_maskFunction · 0.85

Tested by

no test coverage detected