cache/proto1/cache_nest.c
author terom@cl-543.hel-01.fi.sixxs.net
Thu, 07 Aug 2008 20:28:06 +0300
changeset 30 33e464fd6773
permissions -rw-r--r--
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
/*
 * On-disk structs
 */

#pragma pack(push)
#pragma pack(1)

struct cache_nest_header {
    u_int32_t        next_offset;
};

int _cache_nest_assign_op (struct cache *ctx, struct cache_op *op_info, struct cache_nest **nest_info) {
    for (int i = 0; i < CACHE_NEST_COUNT; i++) {
        if (ctx->nests[i].op == NULL) {
            // found an unused nest
            ctx->nests[i].op = op_info;
            *nest_info = ctx->nests[i].op;

            return 0;
        }
    }
    
    // no unused nests
    return -1;
}