Skip to content

Commit

Permalink
Merge pull request #70 from michalbiesek/fix-item-dalloc
Browse files Browse the repository at this point in the history
Use _item_delete in item_get()
  • Loading branch information
michalbiesek authored Aug 22, 2019
2 parents 0473904 + ef84f1b commit c1c5234
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/storage/slab/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ _item_unlink(struct item *it)
PERSLAB_DECR_N(it->id, item_val_byte, it->vlen);
}

static void
_item_delete(struct item **it)
{
log_verb("delete it %p of id %"PRIu8, *it, (*it)->id);

_item_unlink(*it);
_item_dealloc(it);
}

/**
* Return an item if it hasn't been marked as expired, lazily expiring
* item as-and-when needed
Expand All @@ -195,8 +204,7 @@ item_get(const struct bstring *key)

if (_item_expired(it)) {
log_verb("get it '%.*s' expired and nuked", key->len, key->data);
_item_unlink(it);
_item_dealloc(&it);
_item_delete(&it);
return NULL;
}

Expand Down Expand Up @@ -360,15 +368,6 @@ item_update(struct item *it, const struct bstring *val)
log_verb("update it %p of id %"PRIu8, it, it->id);
}

static void
_item_delete(struct item **it)
{
log_verb("delete it %p of id %"PRIu8, *it, (*it)->id);

_item_unlink(*it);
_item_dealloc(it);
}

bool
item_delete(const struct bstring *key)
{
Expand Down

0 comments on commit c1c5234

Please sign in to comment.