cache/proto1/cache_nest.c
changeset 30 33e464fd6773
equal deleted inserted replaced
29:605f4459a294 30:33e464fd6773
       
     1 /*
       
     2  * On-disk structs
       
     3  */
       
     4 
       
     5 #pragma pack(push)
       
     6 #pragma pack(1)
       
     7 
       
     8 struct cache_nest_header {
       
     9     u_int32_t        next_offset;
       
    10 };
       
    11 
       
    12 int _cache_nest_assign_op (struct cache *ctx, struct cache_op *op_info, struct cache_nest **nest_info) {
       
    13     for (int i = 0; i < CACHE_NEST_COUNT; i++) {
       
    14         if (ctx->nests[i].op == NULL) {
       
    15             // found an unused nest
       
    16             ctx->nests[i].op = op_info;
       
    17             *nest_info = ctx->nests[i].op;
       
    18 
       
    19             return 0;
       
    20         }
       
    21     }
       
    22     
       
    23     // no unused nests
       
    24     return -1;
       
    25 }
       
    26