omap-iter.c 832 Bytes
Newer Older
1 2 3 4 5 6
/*
 * (C) 2017 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */
#include <stdlib.h>
7
#include <stdio.h>
8 9 10 11 12 13 14 15
#include "libmobject-store.h"
#include "src/omap-iter/omap-iter-impl.h"

int mobject_store_omap_get_next(mobject_store_omap_iter_t iter,
                                char **key,
                                char **val,
                                size_t *len)
{
16 17 18 19 20 21
    if(iter->current == NULL) {
        *key = NULL;
        *val = NULL;
        *len = 0;
        return -1;
    }
22 23 24 25 26

    *key = iter->current->key;
    *val = iter->current->value;
    *len = iter->current->value_size;
    iter->current = iter->current->next;
27
    if(iter->current == iter->head) iter->current = NULL;
28 29 30 31 32 33 34 35

    return 0;
}

void mobject_store_omap_get_end(mobject_store_omap_iter_t iter)
{
    omap_iter_free(iter);
}