Welcome to little lamb

Code » limb » release » tree

[release] / src / liblimb / hmap.h / lookup.c

/* This file is part of limb                           https://lila.oss/limb
 * Copyright (C) 2023 Olivier Brunel                          jjk@jjacky.com */
/* SPDX-License-Identifier: GPL-2.0-only */
#include "hmap.h"

struct item *
lookup(u32 key, hmap *hmap)
{
    struct item *it;
    u32 i, j;

    for (i = key, j = 1; ; i += j++) {
        it = ITEM(i & hmap->sa.a, hmap);
        if (!it->key || it->key == key)
            break;
    }

    return it;
}