bitmap: use external iterator

Reuse the Iterator object from hashmap.h and expose a similar API.

This allows us to do

{
    Iterator i;
    unsigned n;

    BITMAP_FOREACH(n, b, i) {
        Iterator j;
        unsigned m;

        BITMAP_FOREACH(m, b, j) {
            ...
        }
    }
}

without getting confused. Requested by David.
This commit is contained in:
Tom Gundersen
2015-07-16 14:11:12 +02:00
parent 443a559813
commit cb57dd4159
5 changed files with 17 additions and 22 deletions
+2 -1
View File
@@ -536,6 +536,7 @@ fail:
}
static int dns_packet_append_types(DnsPacket *p, Bitmap *types, size_t *start) {
Iterator i;
uint8_t window = 0;
uint8_t len = 0;
uint8_t bitmaps[32] = {};
@@ -548,7 +549,7 @@ static int dns_packet_append_types(DnsPacket *p, Bitmap *types, size_t *start) {
saved_size = p->size;
BITMAP_FOREACH(n, types) {
BITMAP_FOREACH(n, types, i) {
uint8_t entry;
assert(n <= 0xffff);
+2 -1
View File
@@ -527,10 +527,11 @@ static int format_timestamp_dns(char *buf, size_t l, time_t sec) {
static char *format_types(Bitmap *types) {
_cleanup_strv_free_ char **strv = NULL;
_cleanup_free_ char *str = NULL;
Iterator i;
unsigned type;
int r;
BITMAP_FOREACH(type, types) {
BITMAP_FOREACH(type, types, i) {
if (dns_type_to_string(type)) {
r = strv_extend(&strv, strdup(dns_type_to_string(type)));
if (r < 0)