예제 #1
0
파일: slab.c 프로젝트: smushroom/libmm
static int slab_free_obj(kmem_cache_t *cachep, struct slab *slabp, void *objp)
{
    if(cachep == NULL || slabp == NULL || objp == NULL)
    {
        return -1;
    }

    struct list_head *item = NULL;

    unsigned int objnr = obj_to_index(cachep, slabp, objp);
    if(objnr > cachep->obj_num)
    {
        return -2;
    }

    slab_bufctl(slabp)[objnr] = slabp->free;
    set_slab_free(slabp, objnr);
    dec_slab_use(slabp);

    /* move to the free list */
    if(slabp->inuse == 0)
    {
        item = &(slabp->list);
        list_del(item);
        list_add(item, &(cachep->kmem_lists.free));
    }

    inc_cache_free(cachep);

    return 0;
}
예제 #2
0
파일: slab.c 프로젝트: softirq/common
int slab_free_obj(struct kmem_cache_t *cachep, struct slab *slabp, void *objp)
{
    if(cachep == NULL || slabp == NULL || objp == NULL)
        return -1;

    struct list_head *item = NULL;

    unsigned int objnr = obj_to_index(cachep, slabp, objp);
    if(objnr > cachep->obj_num)
        return -2;
    slab_bufctl(slabp)[objnr] = slabp->free;
    slabp->free = objnr;
    slabp->inuse--;

    /* move to the free list */
    if(slabp->inuse == 0)
    {
        item = &(slabp->list);
        list_del(item);
        list_add(item, &(cachep->lists.free));
    }

    return 0;
}