Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug. #200

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions xdl-algorithm-solution/TDM/src/tdm/bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ limitations under the License.
#include <stdint.h>
#include <string.h>

#include <algorithm>

namespace tdm {

Bitmap::Bitmap(): data_(NULL), capacity_(0) {
Expand Down Expand Up @@ -91,9 +93,10 @@ bool Bitmap::set_filter(size_t index, bool filter) {
if (data_ != NULL && capacity_ > 0) {
memcpy(new_data, data_, capacity_);
}
data_ = new_data;

std::swap(data_, new_data);
capacity_ = cap;
free(data_);
free(new_data);
}

uint64_t* ptr = reinterpret_cast<uint64_t*>(data_);
Expand Down
2 changes: 1 addition & 1 deletion xdl/ps-plus/ps-plus/common/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Status {

Status(const Status& s) : state_(s.state_ == nullptr ? nullptr : new State(*s.state_)) {}
void operator=(const Status& s) {
if (!state_) delete state_;
if (state_) delete state_;
state_ = s.state_ == nullptr ? nullptr : new State(*s.state_);
}

Expand Down
2 changes: 1 addition & 1 deletion xdl/xdl/core/lib/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Status {
Status(const Status& s)
: state_(s.state_ == nullptr ? nullptr : new State(*s.state_)) {}
void operator=(const Status& s) {
if (!state_) delete state_;
if (state_) delete state_;
state_ = s.state_ == nullptr ? nullptr : new State(*s.state_);
}

Expand Down