- size_t count = (bound + sizeof (doc_ids->bitmap[0]) - 1) /
- sizeof (doc_ids->bitmap[0]);
- unsigned int *bitmap = talloc_zero_array (ctx, unsigned int, count);
+ unsigned int max = 0;
+ unsigned int *bitmap;
+
+ for (unsigned int i = 0; i < arr->len; i++)
+ max = MAX(max, g_array_index (arr, unsigned int, i));
+ bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));