Skip to content

Commit

Permalink
Change the return value of DB::Delete and DBImpl::Delete to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
huangjiahua committed Jul 3, 2019
1 parent 0ec5dc2 commit 8ab913e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/rsdb/rsdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DB {

bool Get(const std::string &key, std::string *data);

int Delete(const std::string &key);
bool Delete(const std::string &key);

bool Valid() const;

Expand Down
2 changes: 1 addition & 1 deletion src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool rsdb::DB::Get(const std::string &key, std::string *data) {
return ret;
}

int rsdb::DB::Delete(const std::string &key) {
bool rsdb::DB::Delete(const std::string &key) {
Slice key_slice(key);
return impl_->Delete(key_slice);
}
Expand Down
8 changes: 4 additions & 4 deletions src/db_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,19 @@ char *rsdb::DB::DBImpl::DBReadDat() {
return (this->datbuf);
}

int rsdb::DB::DBImpl::Delete(const rsdb::Slice &key) {
int rc = 0;
bool rsdb::DB::DBImpl::Delete(const rsdb::Slice &key) {
bool ret = true;

if (DBFindAndLock(key, true) == 0) {
DBDoDelete();
this->cnt_delok++;
} else {
rc = -1;
ret = false;
this->cnt_delerr++;
}
if (un_lock(this->idxfd, this->chainoff, SEEK_SET, 1) < 0)
err_dump("DBImpl::Delete: un_lock error");
return (rc);
return ret;
}

void rsdb::DB::DBImpl::DBDoDelete() {
Expand Down
2 changes: 1 addition & 1 deletion src/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct rsdb::DB::DBImpl {

bool Get(const Slice &key, Slice *data);

int Delete(const Slice &key);
bool Delete(const Slice &key);

bool Valid() const;

Expand Down

0 comments on commit 8ab913e

Please sign in to comment.