Skip to content
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
4 changes: 4 additions & 0 deletions include/tlsh_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class TlshImpl
public:
TlshImpl();
~TlshImpl();

public:
TlshImpl& operator=(const TlshImpl& other);

public:
void update(const unsigned char* data, unsigned int len);
void fast_update(const unsigned char* data, unsigned int len);
Expand Down
28 changes: 28 additions & 0 deletions src/tlsh_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,34 @@ TlshImpl::~TlshImpl()
delete [] this->lsh_code;
}

TlshImpl& TlshImpl::operator=(const TlshImpl& other)
{
if (this == &other)
return *this;

if (other.a_bucket != NULL) {
if (this->a_bucket == NULL) {
this->a_bucket = new unsigned int[BUCKETS];
}
memcpy(this->a_bucket, other.a_bucket, BUCKETS*sizeof(*this->a_bucket));
} else {
delete [] this->a_bucket; this->a_bucket = NULL;
}
memcpy(this->slide_window, other.slide_window, SLIDING_WND_SIZE);
this->data_len = other.data_len;
this->lsh_bin = other.lsh_bin;
if (other.lsh_code != NULL) {
if (this->lsh_code == NULL) {
this->lsh_code = new char[TLSH_STRING_LEN_REQ+1];
}
memcpy(this->lsh_code, other.lsh_code, TLSH_STRING_LEN_REQ+1);
} else {
delete [] this->lsh_code; this->lsh_code = NULL;
}
this->lsh_code_valid = other.lsh_code_valid;
return *this;
}

void TlshImpl::reset()
{
delete [] this->a_bucket; this->a_bucket = NULL;
Expand Down