From 8ab913e97ce39d03ebb7a78dd9a53e524517fa12 Mon Sep 17 00:00:00 2001 From: huangjiahua Date: Wed, 3 Jul 2019 20:42:50 +0800 Subject: [PATCH] Change the return value of DB::Delete and DBImpl::Delete to bool --- include/rsdb/rsdb.h | 2 +- src/db.cpp | 2 +- src/db_impl.cpp | 8 ++++---- src/db_impl.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/rsdb/rsdb.h b/include/rsdb/rsdb.h index 48bbd84..ad24c55 100644 --- a/include/rsdb/rsdb.h +++ b/include/rsdb/rsdb.h @@ -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; diff --git a/src/db.cpp b/src/db.cpp index ddc1204..43c9d76 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -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); } diff --git a/src/db_impl.cpp b/src/db_impl.cpp index 8aced21..9cd9416 100644 --- a/src/db_impl.cpp +++ b/src/db_impl.cpp @@ -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() { diff --git a/src/db_impl.h b/src/db_impl.h index 42b2fe1..4660006 100644 --- a/src/db_impl.h +++ b/src/db_impl.h @@ -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;